fork(1) download
  1. #include <iostream>
  2. #include <memory>
  3. #include <vector>
  4. using namespace std;
  5.  
  6. class A {
  7. public:
  8. A(std::vector<std::shared_ptr<int>>){}
  9. };
  10.  
  11. int main() {
  12.  
  13. auto x = std::make_shared<int>(0);
  14. auto y = std::make_shared<int>(1);
  15.  
  16. auto list = {x, y};
  17. auto res = std::make_shared<A>({{x, y}});
  18.  
  19. return 0;
  20. }
Compilation error #stdin compilation error #stdout 0s 3472KB
stdin
Standard input is empty
compilation info
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
stdout
Standard output is empty