std::is_tr1_tuple<T> - how?
Hi! 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. best regards, Markus
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
Markus Werle wrote:
John Maddock
writes: template
char is_tr1_tuple_test(const std::tr1::tuple &); Unfortunately the syntax "T1....T10" as template argument seems not to be implemneted for vc8 ...
Sorry, that was shorthand for writing out in full
template
John Maddock
Markus Werle wrote:
John Maddock
writes: template
char is_tr1_tuple_test(const std::tr1::tuple &); Unfortunately the syntax "T1....T10" as template argument seems not to be implemneted for vc8 ...
Sorry, that was shorthand for writing out in full
template
But this code then only works if and only if the maximum number of arguments is exactly 10, right? Markus
Markus Werle:
template
char is_tr1_tuple_test(const std::tr1::tuple &);
...
But this code then only works if and only if the maximum number of arguments is exactly 10, right?
It should work for tuples with up to ten parameters, even if the maximum is higher. (I think that the straightforward partial specialization approach should, too.)
Markus Werle wrote:
But this code then only works if and only if the maximum number of arguments is exactly 10, right?
I hope not :-( Because it's a function overload (rather than a template partial specialisation) it should work as long as the max number of args is 10 or more. HTH, John.
participants (3)
-
John Maddock
-
Markus Werle
-
Peter Dimov