|
Boost : |
From: Jody Hagins (jody-boost-011304_at_[hidden])
Date: 2005-03-10 16:39:11
The coding guidelines document (boost/more/int_const_guidelines.htm),
states the following...
Always use a fully qualified name to refer to an integral constant
expression.
For example:
typedef myclass< ::boost::is_integral<some_type>::value> mytypedef;
Rationale: at least one compiler (Borland's), doesn't recognise the name
of a constant as an integral constant expression unless the name is
fully qualified (which is to say it starts with ::).
However, it appears that the same compiler (BCB6) has problems if the
'::' is left in. For example...
template <class T>
struct Foo
{
typedef typename ::boost::remove_reference< T >::type type;
typedef typename ::boost::add_reference<
typename ::boost::add_const< type >::type
>::type ref_to_const_type;
};
fails to compile. Initially I thought it had something to do with
typename (e.g., another BOOST_DEDUCED_TYPENAME) because, the first,
simpler line compiles if I remove the "typename" keyword.
Unfortunately, the following does not compile either
template <class T>
struct Foo
{
typedef ::boost::remove_reference< T >::type type;
typedef ::boost::add_reference<
::boost::add_const< type >::type
>::type ref_to_const_type;
};
After seeing a notice on this list a few minutes ago, I decided to
remove the '::' and whaddya know...
template <class T>
struct Foo
{
typedef typename boost::remove_reference< T >::type type;
typedef typename boost::add_reference<
typename boost::add_const< type >::type
>::type ref_to_const_type;
};
this compiles correctly.
So, I am left scratching my head, wondering what to do if I want to use
TypeTraits in a portbale manner.
Thanks!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk