Boost logo

Boost :

From: Jaap Suter (J.Suter_at_[hidden])
Date: 2003-01-12 03:59:23


> > Hi,
>
> Hi Jaap,

Wow, fast reply. Thanks!

> including MSVC 6.5/7.0 (assuming the latest CVS sources). Or are you using
> the 1.29.0 archive?

I have the latest CVS sources (I did a full 'get' over the 1_29_0 release in
case you wonder where the boost_1_29_0 directory comes from in the path
below).

> > but that didn't fix it.
>
> Hmm, works for me, even if I remove the 'plus' inheritance:

You are right, I apologize. I never actually tried the example in the
original post, I just assumed that it was the same as the actual code.
However, after your reply I tried it, and it does in fact compile. So I
tried to come up with the actual smallest example that doesn't compile, even
with the LAMBDA_SUPPORT macro. It looks as follows:

template< class T >
struct meta_fun_1
{
    typedef mpl::integral_c< typename T::value_type, 0 > type;
    BOOST_MPL_AUX_LAMBDA_SUPPORT( 1, meta_fun_1, (T) )
};

template< class List, class T >
struct meta_fun_2
{
    typedef typename mpl::fold< List,
        mpl::integral_c< size_t, 0 >,
        meta_fun_1< mpl::_1 >
>::type type;
};

The problem lies in the fact that I try to use a dependent type in
meta_fun_1. I have pasted the full compiler error at the bottom of the
message (it's rather long). The first few lines say:

'value_type' : is not a member of 'boost::mpl::arg<N>'
with
[
N=1
]
<snip>
e:\library\boost_1_29_0\boost\type_traits\is_convertible.hpp(61) : see
reference to class template instantiation 'test::meta_fun_1<T>' being
compiled
with
[
T=boost::mpl::_1
]

Any suggestions? I can work-around it by using plain integers instead of
::value_type, but it's not as elegant.

> > what compiler-problems they try to fix, and how they do it?
>
> They are compensating the lack of partial template specialization or/and
> template template parameters support by the means of introducing an
> intrusive metafunction's introspection mechanism. The implementation
details
> are gloriously nasty, vary from compiler to compiler, and generally aren't
> worth one's time.

:) haha. I can't even begin to imagine the pain you must have gone through
to get this working. I'm porting something from Intel to other compilers. It
took me a while to get GCC up and running. I kept gettting segmentation
faults (internal compiler errors). It turned out that if I changed this:

    template < ... >
    struct meta_fun
    {
        template < ... >
        struct helper_fun_only_used_here {};

        typedef helper_fun_only_used_here< ... >::type type;
    };

to

     template < ... >
    struct helper_fun_only_used_here {};

    template < ... >
    struct meta_fun
    {
       typedef helper_fun_only_used_here< ... >::type type;
    };

Everything compiled fine. Thus, instead of using an inner-class (because it
is an implementation detail), I just moved it into the enclosing namespace.
How is one suppose to discover that? It was just a guess from my part.

Oh well :). I will add an item to the wiki that moving around meta-functions
in through a scope-hierarchy might some fix certain problems on certain
compilers :).

In case you need it, here is the complete error that MSVC 7 produces with
the above code.

In it, scalar_grade is an mpl::vector_c<> and space is a traits class but
not really important in this case because it's
not used.

____________________________________________

'value_type' : is not a member of 'boost::mpl::arg<N>'
with
[
N=1
]
e:\library\boost_1_29_0\boost\mpl\aux_\preprocessed\msvc70\arg.hpp(28) : see
declaration of 'boost::mpl::arg<N>'
with
[
N=1
]
e:\library\boost_1_29_0\boost\type_traits\is_convertible.hpp(61) : see
reference to class template instantiation 'test::meta_fun_1<T>' being
compiled
with
[
T=boost::mpl::_1
]
e:\library\boost_1_29_0\boost\type_traits\is_convertible.hpp(77) : see
reference to class template instantiation
'boost::detail::does_conversion_exist<From>::result_<To>' being compiled
with
[
From=boost::detail::is_enum_impl<test::meta_fun_1<boost::mpl::_1>>::r_type ,
To=boost::detail::int_convertible
]
e:\library\boost_1_29_0\boost\type_traits\is_convertible.hpp(178) : see
reference to class template instantiation
'boost::detail::is_convertible_impl<From,To>' being compiled
with
[
From=boost::detail::is_enum_impl<test::meta_fun_1<boost::mpl::_1>>::r_type ,
To=boost::detail::int_convertible
]
e:\library\boost_1_29_0\boost\type_traits\is_enum.hpp(54) : see reference to
class template instantiation 'boost::is_convertible<From,To>' being compiled
with
[
From=boost::detail::is_enum_impl<test::meta_fun_1<boost::mpl::_1>>::r_type ,
To=boost::detail::int_convertible
]
e:\library\boost_1_29_0\boost\type_traits\is_enum.hpp(91) : see reference to
class template instantiation
'boost::detail::is_enum_helper<is_typename_arithmetic_or_reference>::type<T>
' being compiled
with
[
is_typename_arithmetic_or_reference=false,
T=boost::detail::is_enum_impl<test::meta_fun_1<boost::mpl::_1>>::r_type
]
e:\library\boost_1_29_0\boost\type_traits\is_enum.hpp(96) : see reference to
class template instantiation 'boost::detail::is_enum_impl<T>' being compiled
with
[
T=test::meta_fun_1<boost::mpl::_1>
]
e:\library\boost_1_29_0\boost\type_traits\is_scalar.hpp(30) : see reference
to class template instantiation 'boost::is_enum<T>' being compiled
with
[
T=test::meta_fun_1<boost::mpl::_1>
]
e:\library\boost_1_29_0\boost\type_traits\is_scalar.hpp(50) : see reference
to class template instantiation 'boost::detail::is_scalar_impl<T>' being
compiled
with
[
T=test::meta_fun_1<boost::mpl::_1>
]
e:\library\boost_1_29_0\boost\type_traits\is_class.hpp(78) : see reference
to class template instantiation 'boost::is_scalar<T>' being compiled
with
[
T=test::meta_fun_1<boost::mpl::_1>
]
e:\library\boost_1_29_0\boost\type_traits\is_class.hpp(93) : see reference
to class template instantiation 'boost::detail::is_class_impl<T>' being
compiled
with
[
T=test::meta_fun_1<boost::mpl::_1>
]
e:\library\boost_1_29_0\boost\mpl\aux_\has_rebind.hpp(32) : see reference to
class template instantiation 'boost::is_class<T>' being compiled
with
[
T=test::meta_fun_1<boost::mpl::_1>
]
e:\library\boost_1_29_0\boost\mpl\aux_\template_arity.hpp(51) : see
reference to class template instantiation 'boost::mpl::aux::has_rebind<T>'
being compiled
with
[
T=test::meta_fun_1<boost::mpl::_1>
]
e:\library\boost_1_29_0\boost\mpl\aux_\preprocessed\msvc70\lambda_no_ctps.hp
p(150) : see reference to class template instantiation
'boost::mpl::aux::template_arity<F>' being compiled
with
[
F=test::meta_fun_1<boost::mpl::_1>
]
e:\library\boost_1_29_0\boost\mpl\fold.hpp(42) : see reference to class
template instantiation 'boost::mpl::lambda<T,Protect>' being compiled
with
[
T=test::meta_fun_1<boost::mpl::_1>,
Protect=true
]
e:\projects\test\test_2d_euclidian.cpp(36) : see reference to class template
instantiation 'boost::mpl::fold<Sequence,State,ForwardOp>' being compiled
with
[
Sequence=scalar_grade,
State=boost::mpl::integral_c<size_t,0>,
ForwardOp=test::meta_fun_1<boost::mpl::_1>
]
e:\projects\test\test_2d_euclidian.cpp(59) : see reference to class template
instantiation 'test::meta_fun_2<List,T>' being compiled
with
[
List=scalar_grade,
T=space
]
e:\projects\test_2d_euclidian.cpp(25) : fatal error C1507: previous user
errors and subsequent error recovery halt further compilation


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk