Boost logo

Boost :

From: scleary_at_[hidden]
Date: 2001-06-27 08:48:21


Last night I converted some code over to use the BOOST_STATIC_CONSTANT
macro, and ran into a problem: any ICE whose value is determined by a
template class that takes two or more parameters (*including* the
metaprogramming helpers provided by <boost/type_traits/ice.hpp>) cannot be
declared with this macro.

That's a mouthful, so here's an example from "ice_guidelines.htm":
  ::boost::type_traits::ice_or<ICE1,ICE2>::value
but you can't declare it using BOOST_STATIC_CONSTANT:
  BOOST_STATIC_CONSTANT(bool, val =
::boost::type_traits::ice_or<ICE1,ICE2>::value);
                                                        syntax error ^

The problem is that there isn't a way to use an expression containing commas
as a value for the 'assignment' macro argument (wrapping it in parenthesis,
the standard way to pass commas in macro arguments, will result in a syntax
error in this case).

This makes two of the guidelines in "ice_guidelines.htm" mutually exclusive.

Bummer.

I recall a little debate a while back over an alternate implementation:
 #ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION
 # define BOOST_STATIC_CONSTANT(type, name, value) enum { name = value }
 #else
 # define BOOST_STATIC_CONSTANT(type, name, value) static const type name =
value
 #endif
which would resolve this issue. That debate was actually about 'name =
value' vs. 'name, value' which I don't really care about; but now this
affects functionality.

OR we can just say that this is an "uncommon occurrence" (it's only used in
non-type template metaprogramming), and let those "uncommon" <wink> people
#ifdef BOOST_NO_INCLASS_MEMBER_INITIALIZATION by hand instead...

Dave, what do you think? Make sweeping change or just declare it uncommon?

        -Steve


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