"David B. Held" <[EMAIL PROTECTED]> writes:

> "Aleksey Gurtovoy" <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]
>> [...]
>>     typedef typename apply<
>>           typename lambda<Policy>::type
>>         , T
>>         >::type p;
>>
>> things should work independently of whenever 'Policy' is in form of
>> 'my_policy<_>' or 'my_policy' - given that the latter is a metafunction
>> class, of course.
>
> Never mind.  It all works as advertised.  I thought a class only had
> to have a nested apply<> struct to be metafunction class, but it
> also needs a typedef .. type; in the *apply*.  I think I tried
> putting in the type, but I put it outside of the apply, which was
> causing my problems.  It seems odd that I have to say:
>
> struct Policy
> {
>     template <typename P>
>     struct apply
>     {
>         typedef apply type;
>         // ...
>     };
> };
>
> I guess that is to be consistent with metafunctions, but for some
> reason I thought that lambda or mpl added the type for you.  

Lambda "adds the type" for cases like std::vector<_1>.  Metafunction
classes, though, are supposed to be the super-efficient way to do
things, so having the library perform extra template instantiations to
detect the nested ::type would probably not be appropriate there.

BTW, normally, you might:

struct Policy
{
    template <class P>
    struct apply
    {
        typename some_other_class type;
    };
};

if nothing else, just to cut down on symbol size (you don't want to
see Policy::apply<...> in your error messages when it could be
some_other_class<...>).


-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to