Corrected initializers are one of the edge cases when the ideal forwarding is not so perfect.
The problem is that the corrected initializers passed to the parameters of the function template are in a non-deduced context, and compilers are not allowed to infer the type for them.
Fortunately, the fix is ββpretty simple: just specify how to use it std::initializer_list
.
my_map.emplace(i, std::initializer_list<std::string>{"foo", "bar"});
The usual way to solve this problem is to do something like:
auto list = { "foo", "bar" };
my_map.emplace(i, list);
std::string
, decltype(list)
std::initializer_list<const char*>
.