The following is the expanded version, which works fine, only I'd like to use an initializer list
vector<shared_ptr<Foo>> inputs = {
make_shared<Foo>("foo"),
make_shared<Foo>("bar"),
make_shared<Foo>("baz")
};
So I've tried something like
vector<shared_ptr<Foo>> inputs2 = {
{ "foo" },
{ "bar" },
{ "baz" }
};
as well as with two brackets, or none, ie {{ "foo" }} and just "foo".
std::shared_ptr<Foo> foo = { "foo" };
doesn't compile either, so I think this isn't a matter of vectors at all, but initializing shared_ptrs with initializer lists.
Aucun commentaire:
Enregistrer un commentaire