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?
yes, sort of.