我缺少std::make_shared
的内容。它不能解析std::initializer_list
的类型,还是我做错了其他事情?
#include <vector>
#include <memory>
class A {};
int main()
{
A a;
std::vector<A> veca{A(),A{},a}; // this works ofc
std::vector<A> vecb({A(),a}); // this too
std::make_shared<std::vector<A>>(vecb); // and this,ofc
std::make_shared<std::vector<A>>({a}); // what's wrong here?
return 0;
}
错误:
main.cpp:21:41: error: too many arguments to function ‘std::shared_ptr<_Tp1> std::make_shared(_Args&& ...) [with _Tp = std::vector; _Args = {}]’
std::make_shared<std::vector<A>>({a});
^
In file included from /usr/include/c++/6/memory:82:0,from main.cpp:10:
/usr/include/c++/6/bits/shared_ptr.h:632:5: note: declared here
make_shared(_Args&&... __args)
^~~~~~~~~~~