Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2002-11-27 21:30:24

"Aleksey Gurtovoy" <agurtovoy_at_[hidden]> wrote in message
> [...]
> > but is this documented?
> Now it is :). Speaking seriously, it's on my documentation to-do list.


Now, for a real stumper. It seems to me that VC6 is only pretending to
compile MPL::Lambda. The reason being that it refuses to recognize
nested types that have passed through lambda. Here's what I think is
the relevant code:

    template <class F, typename T>
    struct apply_lambda
        typedef typename mpl::lambda<F>::type f_;
        typedef typename mpl::apply1<f_, T>::type type;

    template <class Policy>
    struct get_category
        typedef typename Policy::policy_category type;

    template <class Sequence, class Category, class Default>
    struct get_policy
        typedef typename mpl::find_if<
            Sequence, is_same<get_category<_>, Category>
>::type iter_;
        typedef typename mpl::end<Sequence>::type last_;
        typedef typename mpl::apply_if<
            typename is_same<iter_, last_>::type,
            mpl::identity<Default>, iter_
>::type type;

    // decided to make this a class, because it seems to
    // work better
    template <typename T, class Policies>
    struct storage_policy_
        typedef typename apply_lambda<
            typename get_policy<
          Policies, storage_policy_tag, scalar_storage<_>
>::type, T
>::type type;

Now, inside smart_ptr...

    typedef typename storage_policy_<T, policies_>::type storage_policy;
    typedef storage_policy::pointer_type pointer_type;

VC6 really doesn't like the second typedef. It says:

    error C2039: 'pointer_type' : is not a member of '`global namespace''
    error C2146: syntax error : missing ';' before identifier 'pointer_type'
    error C2868: 'pointer_type' : illegal syntax for using-declaration;
            expected qualified-name

If I change the second typedef to this:

    typedef storage_policy_<T, policies_>::type::pointer_type pointer_type;

the first error switches to:

    error C2510: 'type' : left of '::' must be a class/struct/union

and the others remain the same. I included all three error messages in
case it gives you an idea what might be happening. I thought maybe MPL
was not actually performing the type manipulations correctly (in find_if,
etc.), so I put a typedef int* pointer_type; in empty_policy (which I
might have been selected). No effect. If I add the line:

    typedef type::pointer_type pointer_type;

to storage_policy_<>, I simply move the error up to that location. So it's
hard to tell if the types are really making it all the way through Lambda or
not. I know it's not easy to debug this without seeing all the code, but if
you need to see it, I just committed the latest stuff to the sandbox (under
policy_ptr). Thanks for any insight you can provide.


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