0

I do not get why I cannot use initializer_list with variadic templates.

This code:

template <class... TArgs>
void Func(string name, TArgs&&... args)
{
}

Func(string("name1"), { "option1", "option2" });

gives me error:

too many arguments to function 'void Func(std::string, TArgs&& ...) [with TArgs = {}; std::string = std::basic_string<char>]'`
sad1raf
  • 135
  • 9
  • 2
    [This](http://stackoverflow.com/questions/12431495/initializer-list-and-template-type-deduction) applies to your question too. Very Similar – WhiZTiM Mar 17 '17 at 16:14
  • @WhiZTiM thanks. It turned out it has nothing to do with variadic templates. – sad1raf Mar 17 '17 at 16:20

0 Answers0