$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Jaap Suter (J.Suter_at_[hidden])
Date: 2002-12-30 01:11:13
Hi,
what's the current status on using MPL on different compilers? I have looked
at http://www.mywikinet.com/mpl/log.html but it seems not all meta-functions
are listed there.
I'm currently porting a library from Intel to GCC, MSVC7.0 and BorlandC-5.5
and running into some problems. GCC is doing relatively okay. I'm moving
from Borland-5.5 to 6.x soon, so I probably won't even bother with that one.
So that leaves MSVC 7.0. However, compiling even relatively simple
templates, I get errors pointing in the MPL source-code (which is a problem
with MSVC, not with the actual sourcecode of course).
Note, I'm not even instantiating anything yet, this is just the first-phase
compilation of a template definition. For example, consider:
/*!
\brief Meta function, returns the number of bits equal to
1 in a given number.
\param N Some number. Concept: boost::mpl::integral_c
\retval ::type boost::mpl::integral_c< size_t, Number of bits equal
to 1 in
N >
*/
template < typename N >
struct num_bits_set
{
private:
template < typename Number >
struct recurse
{
private:
BOOST_STATIC_CONSTANT( typename Number::value_type,
shift_right_value =
N::value >> 1 );
BOOST_STATIC_CONSTANT( typename Number::value_type,
last_bit_set_value =
N::value & 1 );
typedef mpl::integral_c< size_t, last_bit_set_value > next_value;
public:
typedef typename mpl::plus<
next_value,
typename num_bits_set<
mpl::integral_c<
typename Number::value_type,
shift_right_value > >::type
>::type type;
};
public:
typedef typename mpl::apply_if<
typename mpl::equal_to<
N,
mpl::integral_c<
typename N::value_type,
0 >
>::type,
mpl::integral_c< size_t, 0 >,
recurse< N >
>::type type;
};
Compiling this on MSVC 7.0 gives me the following errors:
e:\library\boost_1_29_0\boost\mpl\arithmetic\plus.hpp(60) : error C2975:
'boost::mpl::plus_c' : invalid template argument for 'N2', constant
expression expected
e:\library\boost_1_29_0\boost\mpl\arithmetic\plus.hpp(41) : see declaration
of 'boost::mpl::plus_c'
e:\projects\boost_1_29_0\boost\math\clifford\aux_.hpp(123) : see reference
to class template instantiation 'boost::mpl::plus<T1,T2,T3,T4,T5>' being
compiled
with
[
T1=boost::math::clifford::aux::num_bits_set<N>::recurse<<template
parameter>>::next_value,
T2=,
T3=boost::mpl::integral_c<int,0>,
T4=boost::mpl::integral_c<int,0>,
T5=boost::mpl::integral_c<int,0>
]
e:\projects\boost_1_29_0\boost\math\clifford\aux_.hpp(113) : see reference
to class template instantiation
'boost::math::clifford::aux::num_bits_set<N>::recurse<<template parameter>>'
being compiled
e:\projects\boost_1_29_0\boost\math\clifford\aux_.hpp(132) : see reference
to class template instantiation
'boost::math::clifford::aux::num_bits_set<N>' being compiled
e:\library\boost_1_29_0\boost\mpl\arithmetic\plus.hpp(61) : error C2504:
'boost::mpl::plus_c<T,N1,N2,N3,N4,N5>' : base class undefined
with
[
T=long,
N1=1,
N2=0,
N3=value,
N4=value,
N5=value
]
e:\projects\boost_1_29_0\boost\math\clifford\aux_.hpp(123) : error C2039:
'type' : is not a member of 'boost::mpl::plus<T1,T2,T3,T4,T5>'
with
[
T1=boost::math::clifford::aux::num_bits_set<N>::recurse<<template
parameter>>::next_value,
T2=,
T3=boost::mpl::integral_c<int,0>,
T4=boost::mpl::integral_c<int,0>,
T5=boost::mpl::integral_c<int,0>
]
Anyway, any hints for the above would be appreciated, but the actual
question is: is it worth it spending a lot of time on an MSVC7 port, or is
this an effort doomed to fail from the start? I suppose this is hard to
answer without knowing the library details and the target-audience, but
considering I'm doing some rather complicated MPL stuff it is going to be
one hell of a ride.
Mmm, perhaps I'm better of waiting for the PTS supporting MSVC update. If
not, any strategies or advice for tackling common problems with MPL on MSVC?
Thanks,
Jaap Suter