Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2002-10-04 21:29:40

David B. Held wrote:
> Ok, this is really frustrating. I'm trying trivial examples to understand
> how lambda expressions work, and I can't get it to compile on bcc or
> gcc. Here's what I'm doing:
> #include <boost/mpl/lambda.hpp>
> #include <boost/mpl/apply.hpp>
> -
> namespace mpl = boost::mpl;
> using mpl::_;
> template <typename T>
> struct ownership
> { };
> int main(int argc, char* argv[])
> {
> typedef mpl::lambda<ownership<_> >::type f_;
> mpl::apply<f_, int>::type t;
> }
> gcc reports that 'type' is not a member of apply<...>. bcc reports:
> [C++ Error] apply.hpp(55): E2404 Dependent type qualifier
> 'ownership<_>' has no member type named 'apply'
> I've tried bind<> too, with no luck. Help!

There are several issues here. First, - and sorry for misleading you - I
completely forgot that even on a conforming compiler in order for the above
to work, 'ownership' class template should be a metafunction:

template <typename T>
struct ownership
    typedef ownership type; // here

I was looking into a way to inform 'mpl::lambda<...>' that in certain cases
it doesn't need to insist on '::type' notation, but at this moment the
typedef is required.

With this change the example should compile cleanly on gcc.

Secondly, as Borland is not conforming, some more intrusive changes are
needed to make 'ownership' template lambda enabled:

template <typename T>
struct ownership
    typedef ownership type;
    struct rebind_;


But my main fault is that the above is not in the CVS yet - sorry! I'll try
to check it in tomorrow (there are still some things to be done about it).


Boost list run by bdawes at, gregod at, cpdaniel at, john at