#include <iostream>
class Foo
{
public:
template <typename Container>
Foo (const Container & args)
{
for (auto arg : args)
std::cout << "ARG(" << arg << ")\n";
}
};
int main ()
{
Foo foo ({"foo", "bar", "baz"});
}
The error (using g++ -std=c++17) is
error: no matching function for call to ‘Foo::Foo(<brace-enclosed initializer list>)’
This works
Foo foo (std::vector<const char*> ({"foo", "bar", "baz"}));
Why can't the initializer-list match the template constructor?