Inheritance gadget for type member in standard?

102 Views Asked by At

When programming with C++ templates, I often find it useful to define a type alias member called type. I've defined a kind of "identity" template:

template <typename T>
struct id { using type = T; };

I quite like that I can then often avoid putting anything between the braces of a class definition; inheriting from an id specialisation instead. A trivial primary template example might then be:

template <typename,typename>
struct Foo : id<void> {};

Does something like id exist in the standard library; or Boost?

1

There are 1 best solutions below

1
On

yes, sort of.

std::enable_if<true, T>