Variadic templates for saving typing

K

Kaba

Hmm.. Should this compile in C++11 (the compiler at Ideone does not)?

template <typename A, typename B>
class C {};

template <typename... TypeSet>
void f(const C<TypeSet...>& c) {}

int main()
{
C<int, int> c;
f(c);
return 0;
}

The idea is to save typing in case I'm not interested in the actual
template-arguments of C.
 
M

Melzzzzz

Hmm.. Should this compile in C++11 (the compiler at Ideone does not)?

template <typename A, typename B>
class C {};

template <typename... TypeSet>
void f(const C<TypeSet...>& c) {}

int main()
{
C<int, int> c;
f(c);
return 0;
}

The idea is to save typing in case I'm not interested in the actual
template-arguments of C.

This works:
template <typename A, typename B>
class C {};

template <template <class...> class C,typename... TypeSet>
void f(const C<TypeSet...>& c) {}

int main()
{
C<int, int> c;
f(c);
return 0;
}
 
K

Kaba

12.8.2012 18:48, Melzzzzz kirjoitti:
This works:
template <typename A, typename B>
class C {};

template <template <class...> class C,typename... TypeSet>
void f(const C<TypeSet...>& c) {}

int main()
{
C<int, int> c;
f(c);
return 0;
}

True, but it matches more than it should:)
 

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
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top