I am trying to initialise an std::vector in a way that is equivalent to an example from Bjarne Stroustrup\'s C++11 FAQ
After "fixing" your example:
#include
#include
#include
int main()
{
std::vector> vs = { { new std::string{"Doug"} }, { new std::string{"Adams"} } }; // fails
std::unique_ptr ps { new std::string{"42"} }; // OK
}
I got very a clear error message:
error: converting to 'std::unique_ptr >' from initializer list would use explicit constructor 'std::unique_ptr<_Tp, _Dp>::unique_ptr(std::unique_ptr<_Tp, _Dp>::pointer) [with _Tp = std::basic_string, _Dp = std::default_delete >, std::unique_ptr<_Tp, _Dp>::pointer = std::basic_string*]'
This error tells us that it is not possible to use the unique_ptr's explicit contructor!