I have a class whose constructor takes an initializer_list
:
Foo::Foo(std::initializer_list bars)
If I attempt to c
A braced initializer has no type. When you call make_unique
it tries to deduce the type and fails. In this case you have to specify the type when calling like
std::make_unique(std::initializer_list{ &b });
This will create a std::initializer_list
which the compiler can deduce and it will forward it to Foo::Foo(std::initializer_list
The reason Foo f ({ &b });
works is that the compiler knows of the constructor Foo(std::initializer_list
and braced initializer list of B*
s can be implicitly converted to a std::initializer_list
. There is not type deduction going on.