specializing function template on initializer_list does not work?

83 Views Asked by At

I know specializing function templates is wrong

This question is out of Curiosity.

say I have a function template

template<typename T>
void foo(T){}

and I specialize it

template<>
void foo(std::initializer_list<int>){}

and I call this like

foo({1, 2, 3});

I get an error "no instance of foo matching brac-enclosed initializer list" pointing to the primary template (overloading works fine as expected)

but if I change the function base template to taking initializer_list as parameter everything is ok.

what exactly is happening?

compiler : gcc 4.8.2 helpful link

0

There are 0 best solutions below