
28 Aug
2012
28 Aug
'12
12:21 p.m.
On 26/08/2012 14:28, pavel wrote:
Mathias wrote on Saturday, August 25, 2012 at 19:31:53:
What's the advantage over
template<class T> struct tag_of;
template<class Derived> struct Base { typedef typename tag_of<Derived>::type tag; };
struct Foo : Base<Foo> { };
template<> struct tag_of<Foo> { typedef void type; };
thanks for the question
the advantage is that you may completely ignore the tag as in
template<typename type> void f(const Base<type>&);
This is also possible with the code above, since the tag is not part of the template parameters of Base.