fork download
  1. #include <iostream>
  2. #include <memory>
  3.  
  4. class Base
  5. {
  6. public:
  7. Base() {}
  8. };
  9.  
  10. class Derived : public Base
  11. {
  12. public:
  13. Derived() {}
  14. Derived(std::initializer_list<std::pair<int, std::shared_ptr<Base>>>) {}
  15. };
  16.  
  17. int main(int argc, char ** argv)
  18. {
  19. // auto example = new Derived({
  20. // { 0, std::make_shared<Derived>() }
  21. // });
  22.  
  23. auto example = new Derived({
  24. { 0, std::make_shared<Derived>({
  25. { 0, std::make_shared<Derived>() }
  26. }) }
  27. });
  28.  
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main(int, char**)’:
prog.cpp:26:10: error: too many arguments to function ‘std::shared_ptr<_Tp1> std::make_shared(_Args&& ...) [with _Tp = Derived; _Args = {}]’
         }) }
          ^
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:23:10: warning: unused variable ‘example’ [-Wunused-variable]
     auto example = new Derived({
          ^
stdout
Standard output is empty