Getting the type of "Tail" in c++0x tuple

A

Andy Venikov

Hi,

I was brwosing the latest FCD (N3092) for ways to get the type of "Tail"
of std::tuple. I don't see any way of doing it.

You can get the type of the Head through tuple_element<>, but not the
type of the rest of the tuple.

Is there a standard way or should I bother creating my own?

Thanks,
Andy.
 
A

Andy Venikov

Andy said:
Hi,

I was brwosing the latest FCD (N3092) for ways to get the type of "Tail"
of std::tuple. I don't see any way of doing it.

You can get the type of the Head through tuple_element<>, but not the
type of the rest of the tuple.

Is there a standard way or should I bother creating my own?

Thanks,
Andy.

Does this seem reasonable:

template <typename Tuple>
struct tuple_tail;

template <>
struct tuple_tail<std::tuple<> >
{
typedef std::tuple<> type;
};

temlate <typename Head, typename ... Tail>
struct tuple_tail< std::tuple<Head, Tail...> >
{
typedef std::tuple<Tail...> type;
};


Thanks,
Andy.
 
A

Andy Venikov

Andy said:
Does this seem reasonable:

template <typename Tuple>
struct tuple_tail;

template <>
struct tuple_tail<std::tuple<> >
{
typedef std::tuple<> type;
};

temlate <typename Head, typename ... Tail>
struct tuple_tail< std::tuple<Head, Tail...> >
{
typedef std::tuple<Tail...> type;
};


Thanks,
Andy.

Hmmm, maybe tuple_tail<tuple<>>::type should be considered ill-formed?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top