|
Boost : |
From: Michael Marcin (mmarcin_at_[hidden])
Date: 2007-04-30 15:32:20
Hi,
I have a snippet of code that looks something like
template< std::size_t N >
class something
{
static const std::size_t count = N;
};
On the RVCT 2.2 compiler this fails to compile with an internal error.
The obvious workaround, and the one chosen by BOOST_STATIC_CONSTANT is
template< std::size_t N >
class something
{
enum { count = N };
};
This compiles but through probably another compiler bug during SFINAE
overload resolution with a streaming operator called with a type of
something it trys to instantiate say boost::is_pod< something<0>::(unamed)
>, fails and the compilation aborts. The workaround for this is to name the
enumeration.
template< std::size_t N >
class something
{
enum stupid_name_for_rvct { count = N };
};
This works fine and I've been using it for a while. However I'm now porting
to MinGW GCC and I have SFINAE overloads which compare for instance
something<0>::count to something<1>::count. MinGW gives a slew of warnings
and eventually aborts the compilation. Using the static const std::size_t
implementation of count it works fine.
Sorry for speaking about the problem in such an unclear way but at the
moment I don't have a simple reproducable case.
This is basically the problem that BOOST_STATIC_CONSTANT was designed to
solve IIUC but I need it to name my enumerations for me under RVCT. Perhaps
something could be done using a slightly decorated line number. This would
restrict you to one use of BOOST_STATIC_CONSTANT per line but that seems
perfectly acceptable to me.
Thanks,
Michael Marcin
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk