Short question: Can I typedef a variadic argument pack? I need template
.
Long version
You can achieve what you want by encapsulating the variadic argument pack in a tuple and later using the following two helper template structs to forward the actual variadic arguments:
template
struct cat;
template
struct cat, std::tuple>
{
typedef std::tuple type;
};
and
template class Receiver>
struct Unpack;
template class Receiver>
struct Unpack, Receiver>
{
typedef Receiver type;
};
your code sample would look like this:
#include
#include
#include
template
struct Cat;
template
struct Cat, std::tuple>
{
typedef std::tuple type;
};
template class Receiver>
struct Unpack;
template class Receiver>
struct Unpack, Receiver>
{
typedef Receiver type;
};
template
struct Forward
{
//typedef Args... args; // Problem here!!
typedef std::tuple args; // Workaround
static const std::size_t size = sizeof...(Args);
};
template class SCont,
template class TCont,
typename SForward = Forward<> ,
typename TForward = Forward<>>
class Bimap
{
//typedef SCont left_type;
//typedef TCont right_type;
typedef typename Unpack, typename SForward::args>::type, SCont>::type left_type; //Workaround
typedef typename Unpack, typename TForward::args>::type, TCont>::type right_type; //Workaround
template struct Relation; // to be implemented
typedef Relation relation_type;
};
int main()
{
Bimap> , Forward>> x;
}
which compiles just fine under gcc 4.6.0