#include <iostream>
#include <memory>
#include <vector>
using namespace std;
class A {
public:
A(std::vector<std::shared_ptr<int>>){}
};
int main() {
auto x = std::make_shared<int>(0);
auto y = std::make_shared<int>(1);
auto list = {x, y};
auto res = std::make_shared<A>({{x, y}});
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWVtb3J5PgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgQSB7CglwdWJsaWM6IAoJQShzdGQ6OnZlY3RvcjxzdGQ6OnNoYXJlZF9wdHI8aW50Pj4pe30KfTsKCmludCBtYWluKCkgewoJCglhdXRvIHggPSBzdGQ6Om1ha2Vfc2hhcmVkPGludD4oMCk7CglhdXRvIHkgPSBzdGQ6Om1ha2Vfc2hhcmVkPGludD4oMSk7CgkKCWF1dG8gbGlzdCA9IHt4LCB5fTsKCWF1dG8gcmVzID0gc3RkOjptYWtlX3NoYXJlZDxBPih7e3gsIHl9fSk7CgkKCXJldHVybiAwOwp9
prog.cpp: In function ‘int main()’:
prog.cpp:17:41: error: too many arguments to function ‘std::shared_ptr<_Tp1> std::make_shared(_Args&& ...) [with _Tp = A; _Args = {}]’
auto res = std::make_shared<A>({{x, y}});
^
In file included from /usr/include/c++/4.8/memory:82:0,
from prog.cpp:2:
/usr/include/c++/4.8/bits/shared_ptr.h:610:5: note: declared here
make_shared(_Args&&... __args)
^
prog.cpp:16:7: warning: unused variable ‘list’ [-Wunused-variable]
auto list = {x, y};
^
In file included from /usr/include/i386-linux-gnu/c++/4.8/bits/c++allocator.h:33:0,
from /usr/include/c++/4.8/bits/allocator.h:46,
from /usr/include/c++/4.8/string:41,
from /usr/include/c++/4.8/bits/locale_classes.h:40,
from /usr/include/c++/4.8/bits/ios_base.h:41,
from /usr/include/c++/4.8/ios:42,
from /usr/include/c++/4.8/ostream:38,
from /usr/include/c++/4.8/iostream:39,
from prog.cpp:1:
/usr/include/c++/4.8/ext/new_allocator.h: In instantiation of ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = A; _Args = {}; _Tp = A]’:
/usr/include/c++/4.8/bits/alloc_traits.h:254:4: required from ‘static typename std::enable_if<std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::value, void>::type std::allocator_traits<_Alloc>::_S_construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = A; _Args = {}; _Alloc = std::allocator<A>; typename std::enable_if<std::allocator_traits<_Alloc>::__construct_helper<_Tp, _Args>::value, void>::type = void]’
/usr/include/c++/4.8/bits/alloc_traits.h:393:57: required from ‘static decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) std::allocator_traits<_Alloc>::construct(_Alloc&, _Tp*, _Args&& ...) [with _Tp = A; _Args = {}; _Alloc = std::allocator<A>; decltype (_S_construct(__a, __p, (forward<_Args>)(std::allocator_traits::construct::__args)...)) = <type error>]’
/usr/include/c++/4.8/bits/shared_ptr_base.h:400:38: required from ‘std::_Sp_counted_ptr_inplace<_Tp, _Alloc, _Lp>::_Sp_counted_ptr_inplace(_Alloc, _Args&& ...) [with _Args = {}; _Tp = A; _Alloc = std::allocator<A>; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/4.8/ext/new_allocator.h:120:4: required from ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::_Sp_counted_ptr_inplace<A, std::allocator<A>, (__gnu_cxx::_Lock_policy)2u>; _Args = {const std::allocator<A>}; _Tp = std::_Sp_counted_ptr_inplace<A, std::allocator<A>, (__gnu_cxx::_Lock_policy)2u>]’
/usr/include/c++/4.8/bits/alloc_traits.h:254:4: [ skipping 2 instantiation contexts, use -ftemplate-backtrace-limit=0 to disable ]
/usr/include/c++/4.8/bits/shared_ptr_base.h:523:37: required from ‘std::__shared_count<_Lp>::__shared_count(std::_Sp_make_shared_tag, _Tp*, const _Alloc&, _Args&& ...) [with _Tp = A; _Alloc = std::allocator<A>; _Args = {}; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/4.8/bits/shared_ptr_base.h:986:35: required from ‘std::__shared_ptr<_Tp, _Lp>::__shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<A>; _Args = {}; _Tp = A; __gnu_cxx::_Lock_policy _Lp = (__gnu_cxx::_Lock_policy)2u]’
/usr/include/c++/4.8/bits/shared_ptr.h:316:64: required from ‘std::shared_ptr<_Tp>::shared_ptr(std::_Sp_make_shared_tag, const _Alloc&, _Args&& ...) [with _Alloc = std::allocator<A>; _Args = {}; _Tp = A]’
/usr/include/c++/4.8/bits/shared_ptr.h:598:39: required from ‘std::shared_ptr<_Tp1> std::allocate_shared(const _Alloc&, _Args&& ...) [with _Tp = A; _Alloc = std::allocator<A>; _Args = {}]’
/usr/include/c++/4.8/bits/shared_ptr.h:614:42: required from ‘std::shared_ptr<_Tp1> std::make_shared(_Args&& ...) [with _Tp = A; _Args = {}]’
prog.cpp:17:41: required from here
/usr/include/c++/4.8/ext/new_allocator.h:120:4: error: no matching function for call to ‘A::A()’
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^
/usr/include/c++/4.8/ext/new_allocator.h:120:4: note: candidates are:
prog.cpp:8:2: note: A::A(std::vector<std::shared_ptr<int> >)
A(std::vector<std::shared_ptr<int>>){}
^
prog.cpp:8:2: note: candidate expects 1 argument, 0 provided
prog.cpp:6:7: note: constexpr A::A(const A&)
class A {
^
prog.cpp:6:7: note: candidate expects 1 argument, 0 provided
prog.cpp:6:7: note: constexpr A::A(A&&)
prog.cpp:6:7: note: candidate expects 1 argument, 0 provided