|
Boost : |
Subject: Re: [boost] a (useful?) crtp trick
From: Mathias Gaunard (mathias.gaunard_at_[hidden])
Date: 2012-08-28 08:21:01
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.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk