|
Boost Users : |
From: John Maddock (john_at_[hidden])
Date: 2008-08-25 05:26:39
Markus Werle wrote:
> While migrating from boost::tuple to std::tr1::tuple (pain!) I have to
> rewrite a lot of compile-time-magic code.
> Among other things I am in need of a type info
>
> template <typename T> struct is_tr1_tuple;
>
> Any implementation hint or proposal welcome.
This is tricky, when BOOST_HAS_TR1_TUPLE is *not* defined, then
std::tr1::tuple is an alias for either boost::fusion::tuple or boost::tuple
(the latter for broken Borland compilers only), so your existing metacode
should work.
When BOOST_HAS_TR1_TUPLE *is* defined then std::tr1::tuple is the std lib's
native implementation, you could probably use function overload resolution
to detect that:
template <class T1, class T2 ... class T10>
char is_tr1_tuple_test(const std::tr1::tuple<T1....T10>&);
template <class T>
double is_tr1_tuple_test(const T&);
template <class T>
struct is_tr1_tuple
{
static const T m_t;
static const bool value = sizeof(is_tr1_tuple_test(m_t) == 1;
};
In fact I think that should work for the case that BOOST_HAS_TR1_TUPLE is
not defined as well?
HTH, John.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net