fork download
  1. // JsonHolder II.cpp : アプリケーションのエントリ ポイントを定義します。
  2. //
  3. #include <iostream>
  4. #include <cstdint>
  5. #include <map>
  6. #include <vector>
  7. #include <memory>
  8. #include <string>
  9.  
  10.  
  11. class ObjectBase {
  12. public:
  13. enum class Type : std::int8_t {
  14. Uninitialized,
  15. Integer,
  16. Number,
  17. Boolean,
  18. String,
  19. Null,
  20. Array,
  21. Map,
  22. End,
  23.  
  24. };
  25. template<class T>
  26. T* Cast() {
  27. return static_cast<T*>(this);
  28. }
  29.  
  30. virtual const std::string& ToString() {
  31. return "";
  32. }
  33.  
  34. const Type& MyType() {
  35. return T;
  36. }
  37. virtual ~ObjectBase() {}
  38.  
  39. protected:
  40. Type T = Type::Uninitialized;
  41. };
  42. class String:public ObjectBase {
  43. String() {
  44. T = Type::String;
  45. }
  46. String(const std::string& In): D(In){
  47. T = Type::String;
  48. }
  49. virtual ~String() {}
  50.  
  51. const std::string& Get() {
  52. return D;
  53. }
  54. bool Set(const std::string& In) {
  55. D = In;
  56. return true;
  57. }
  58.  
  59. const std::string& ToString() {
  60. return '\"' + D + '\"';
  61. }
  62.  
  63.  
  64. protected:
  65. std::string D;
  66.  
  67. };
  68. class Boolean:public ObjectBase {
  69. Boolean() {
  70. T = Type::Boolean;
  71. }
  72. Boolean(const bool& In): D(In){
  73. T = Type::Boolean;
  74. }
  75. virtual ~Boolean() {}
  76.  
  77. const bool& Get() {
  78. return D;
  79. }
  80. bool Set(const bool&In) {
  81. D = In;
  82. return true;
  83. }
  84. const std::string& ToString() {
  85. return D ? "true" : "false";
  86. }
  87.  
  88. protected:
  89. bool D;
  90. };
  91. class Integer:public ObjectBase {
  92. Integer() {
  93. T = Type::Integer;
  94. }
  95. Integer(const std::int64_t& In): D(In){
  96. T = Type::Integer;
  97. }
  98. virtual ~Integer() {}
  99.  
  100. const std::uint64_t& Get() {
  101. return D;
  102. }
  103.  
  104. bool Set(const std::uint64_t& In) {
  105. D = In;
  106. return true;
  107. }
  108.  
  109. const std::string& ToString() {
  110. return std::to_string(D);
  111. }
  112.  
  113. protected:
  114. std::uint64_t D;
  115. };
  116. class Number:public ObjectBase {
  117. Number() {
  118. T = Type::Number;
  119. }
  120. Number(const double& In): D(In){
  121. T = Type::Number;
  122. }
  123. virtual ~Number() {}
  124.  
  125. const double& Get() {
  126. return D;
  127. }
  128.  
  129. bool Set(const double& In) {
  130. D = In;
  131. return true;
  132. }
  133. const virtual std::string& to_string() {
  134. return std::to_string(D);
  135. }
  136. const std::string& ToString() {
  137. return to_string();
  138. }
  139.  
  140. protected:
  141. double D;
  142. };
  143. class Null:public ObjectBase {
  144. Null() {
  145. T = Type::Null;
  146. }
  147. Null(const std::int64_t& In){
  148. T = Type::Null;
  149. }
  150. virtual ~Null() {}
  151.  
  152. const std::string& ToString() {
  153. return "null";
  154. }
  155. };
  156.  
  157. typedef std::unique_ptr<ObjectBase> UniqueObject;
  158.  
  159. class Array:public ObjectBase {
  160. Array() {
  161. T = Type::Array;
  162. }
  163. Array(const std::initializer_list<UniqueObject>& IL):D(IL.begin(),IL.end()) {
  164. T = Type::Array;
  165. }
  166. virtual ~Array() {}
  167.  
  168. bool Add(UniqueObject&& UO) {
  169. D.push_back(std::forward<UniqueObject&&>(UO));
  170. }
  171. const std::vector<UniqueObject>& Get() {
  172. return D;
  173. }
  174.  
  175. const std::string& ToString() {
  176. std::string R;
  177. R += '[';
  178.  
  179. for (auto& o : D) {
  180. if (o->MyType() == Type::Array) {
  181. R += o->ToString();
  182. continue;
  183. }
  184. if (o->MyType() == Type::Map) {
  185. R += o->ToString();
  186. continue;
  187. }
  188. R += o->ToString();
  189. }
  190.  
  191. R += ']';
  192.  
  193. return R;
  194. }
  195.  
  196. const UniqueObject& operator [](std::size_t I) {
  197. return D[I];
  198. }
  199.  
  200. protected:
  201. std::vector<UniqueObject> D;
  202. };
  203.  
  204. class Map:public ObjectBase {
  205. protected:
  206. class PCmp {
  207. public:
  208. bool operator ()(const UniqueObject& A, const UniqueObject& B)const { return A->ToString() < B->ToString(); };
  209. };
  210. public:
  211. Map() {
  212. T = Type::Map;
  213. }
  214. /**/
  215. Map(std::initializer_list<std::pair<UniqueObject,UniqueObject>>& IL){
  216. T = Type::Map;
  217. auto it = IL.begin();
  218. while (it != IL.end()) {
  219. D.insert(std::make_pair( std::move(it->first), std::move(it->second)));
  220. it++;
  221. }
  222. }
  223. /**/
  224. virtual ~Map() {}
  225.  
  226. bool Add(std::pair<UniqueObject,UniqueObject>& In) {
  227. //D.emplace(std::move(In.first), std::move(In.second));
  228. D[In.first] = std::move(In.second);
  229. }
  230. const std::map<UniqueObject,UniqueObject,PCmp>& Get() {
  231. return D;
  232. }
  233.  
  234. const std::string& ToString() {
  235. std::string R;
  236. R += '{';
  237.  
  238. for (auto& o : D) {
  239. R += o.first->ToString()+" : ";
  240. if (o.second->MyType() == Type::Array) {
  241. R += o.second->ToString();
  242. continue;
  243. }
  244. if (o.second->MyType() == Type::Map) {
  245. R += o.second->ToString();
  246. continue;
  247. }
  248. R += o.second->ToString();
  249. }
  250.  
  251. R += '}';
  252.  
  253. return R;
  254. }
  255.  
  256. const UniqueObject& operator [](const UniqueObject& I) {
  257. return D[I];
  258. }
  259.  
  260. protected:
  261. std::map < UniqueObject, UniqueObject,PCmp> D;
  262. };
  263.  
  264.  
  265.  
  266.  
  267. int main()
  268. {
  269. return 0;
  270. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In member function ‘virtual const string& ObjectBase::ToString()’:
prog.cpp:31:10: warning: returning reference to temporary [-Wreturn-local-addr]
   return "";
          ^~
prog.cpp: In member function ‘virtual const string& String::ToString()’:
prog.cpp:60:21: warning: returning reference to temporary [-Wreturn-local-addr]
   return '\"' + D + '\"';
                     ^~~~
prog.cpp: In member function ‘virtual const string& Boolean::ToString()’:
prog.cpp:85:23: warning: returning reference to temporary [-Wreturn-local-addr]
   return D ? "true" : "false";
                       ^~~~~~~
prog.cpp: In member function ‘virtual const string& Integer::ToString()’:
prog.cpp:110:26: warning: returning reference to temporary [-Wreturn-local-addr]
   return std::to_string(D);
                          ^
prog.cpp: In member function ‘virtual const string& Number::to_string()’:
prog.cpp:134:26: warning: returning reference to temporary [-Wreturn-local-addr]
   return std::to_string(D);
                          ^
prog.cpp: In member function ‘virtual const string& Null::ToString()’:
prog.cpp:153:10: warning: returning reference to temporary [-Wreturn-local-addr]
   return "null";
          ^~~~~~
prog.cpp: In member function ‘virtual const string& Array::ToString()’:
prog.cpp:176:15: warning: reference to local variable ‘R’ returned [-Wreturn-local-addr]
   std::string R;
               ^
In file included from /usr/include/c++/6/bits/stl_algobase.h:64:0,
                 from /usr/include/c++/6/bits/char_traits.h:39,
                 from /usr/include/c++/6/ios:40,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:3:
/usr/include/c++/6/bits/stl_pair.h: In instantiation of ‘constexpr std::pair<typename std::__decay_and_strip<_Tp>::__type, typename std::__decay_and_strip<_T2>::__type> std::make_pair(_T1&&, _T2&&) [with _T1 = const std::unique_ptr<ObjectBase>; _T2 = const std::unique_ptr<ObjectBase>; typename std::__decay_and_strip<_T2>::__type = std::unique_ptr<ObjectBase>; typename std::__decay_and_strip<_Tp>::__type = std::unique_ptr<ObjectBase>]’:
prog.cpp:219:72:   required from here
/usr/include/c++/6/bits/stl_pair.h:498:14: error: no matching function for call to ‘std::pair<std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >::pair(const std::unique_ptr<ObjectBase>, const std::unique_ptr<ObjectBase>)’
       return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_pair.h:423:9: note: candidate: template<class ... _Args1, long unsigned int ..._Indexes1, class ... _Args2, long unsigned int ..._Indexes2> std::pair<_T1, _T2>::pair(std::tuple<_Args1 ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes1 ...>, std::_Index_tuple<_Indexes2 ...>)
         pair(tuple<_Args1...>&, tuple<_Args2...>&,
         ^~~~
/usr/include/c++/6/bits/stl_pair.h:423:9: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:498:14: note:   types ‘std::tuple<_Args1 ...>’ and ‘const std::unique_ptr<ObjectBase>’ have incompatible cv-qualifiers
       return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_pair.h:356:9: note: candidate: template<class ... _Args1, class ... _Args2> std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::tuple<_Args1 ...>, std::tuple<_Args2 ...>)
         pair(piecewise_construct_t, tuple<_Args1...>, tuple<_Args2...>);
         ^~~~
/usr/include/c++/6/bits/stl_pair.h:356:9: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:498:14: note:   ‘std::unique_ptr<ObjectBase>’ is not derived from ‘std::tuple<_Args1 ...>’
       return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_pair.h:351:21: note: candidate: template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<std::unique_ptr<ObjectBase>, _U1>::value) || (! std::is_same<std::unique_ptr<ObjectBase>, _U2>::value)), std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >::_MoveConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<std::unique_ptr<ObjectBase>, _U1>::value) || (! std::is_same<std::unique_ptr<ObjectBase>, _U2>::value)), std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >::_ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&)
  explicit constexpr pair(pair<_U1, _U2>&& __p)
                     ^~~~
/usr/include/c++/6/bits/stl_pair.h:351:21: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:498:14: note:   types ‘std::pair<_T1, _T2>’ and ‘const std::unique_ptr<ObjectBase>’ have incompatible cv-qualifiers
       return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_pair.h:341:12: note: candidate: template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<std::unique_ptr<ObjectBase>, _U1>::value) || (! std::is_same<std::unique_ptr<ObjectBase>, _U2>::value)), std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >::_MoveConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<std::unique_ptr<ObjectBase>, _U1>::value) || (! std::is_same<std::unique_ptr<ObjectBase>, _U2>::value)), std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >::_ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(std::pair<_U1, _U2>&&)
  constexpr pair(pair<_U1, _U2>&& __p)
            ^~~~
/usr/include/c++/6/bits/stl_pair.h:341:12: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:498:14: note:   types ‘std::pair<_T1, _T2>’ and ‘const std::unique_ptr<ObjectBase>’ have incompatible cv-qualifiers
       return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_pair.h:331:21: note: candidate: template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && (! _ImplicitlyMoveConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&)
  explicit constexpr pair(_U1&& __x, _U2&& __y)
                     ^~~~
/usr/include/c++/6/bits/stl_pair.h:331:21: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:330:38: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
                          bool>::type=false>
                                      ^~~~~
/usr/include/c++/6/bits/stl_pair.h:330:38: note: invalid template non-type parameter
/usr/include/c++/6/bits/stl_pair.h:322:12: note: candidate: template<class _U1, class _U2, typename std::enable_if<(_MoveConstructiblePair<_U1, _U2>() && _ImplicitlyMoveConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, _U2&&)
  constexpr pair(_U1&& __x, _U2&& __y)
            ^~~~
/usr/include/c++/6/bits/stl_pair.h:322:12: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:321:38: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
                          bool>::type=true>
                                      ^~~~
/usr/include/c++/6/bits/stl_pair.h:321:38: note: invalid template non-type parameter
/usr/include/c++/6/bits/stl_pair.h:313:17: note: candidate: template<class _U2, typename std::enable_if<_CopyMovePair<false, std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >, _U2>(), bool>::type <anonymous> > std::pair<_T1, _T2>::pair(const _T1&, _U2&&)
        explicit pair(const _T1& __x, _U2&& __y)
                 ^~~~
/usr/include/c++/6/bits/stl_pair.h:313:17: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:312:38: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
                          bool>::type=false>
                                      ^~~~~
/usr/include/c++/6/bits/stl_pair.h:312:38: note: invalid template non-type parameter
/usr/include/c++/6/bits/stl_pair.h:306:18: note: candidate: template<class _U2, typename std::enable_if<_CopyMovePair<true, std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >, _U2>(), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const _T1&, _U2&&)
        constexpr pair(const _T1& __x, _U2&& __y)
                  ^~~~
/usr/include/c++/6/bits/stl_pair.h:306:18: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:305:38: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
                          bool>::type=true>
                                      ^~~~
/usr/include/c++/6/bits/stl_pair.h:305:38: note: invalid template non-type parameter
/usr/include/c++/6/bits/stl_pair.h:299:27: note: candidate: template<class _U1, typename std::enable_if<_MoveCopyPair<false, _U1, std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> > >(), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&)
        explicit constexpr pair(_U1&& __x, const _T2& __y)
                           ^~~~
/usr/include/c++/6/bits/stl_pair.h:299:27: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:298:38: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
                          bool>::type=false>
                                      ^~~~~
/usr/include/c++/6/bits/stl_pair.h:298:38: note: invalid template non-type parameter
/usr/include/c++/6/bits/stl_pair.h:292:18: note: candidate: template<class _U1, typename std::enable_if<_MoveCopyPair<true, _U1, std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> > >(), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(_U1&&, const _T2&)
        constexpr pair(_U1&& __x, const _T2& __y)
                  ^~~~
/usr/include/c++/6/bits/stl_pair.h:292:18: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:291:38: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
                          bool>::type=true>
                                      ^~~~
/usr/include/c++/6/bits/stl_pair.h:291:38: note: invalid template non-type parameter
/usr/include/c++/6/bits/stl_pair.h:285:17: note: candidate: constexpr std::pair<_T1, _T2>::pair(std::pair<_T1, _T2>&&) [with _T1 = std::unique_ptr<ObjectBase>; _T2 = std::unique_ptr<ObjectBase>]
       constexpr pair(pair&&) = default;
                 ^~~~
/usr/include/c++/6/bits/stl_pair.h:285:17: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/6/bits/stl_pair.h:281:21: note: candidate: template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<std::unique_ptr<ObjectBase>, _U1>::value) || (! std::is_same<std::unique_ptr<ObjectBase>, _U2>::value)), std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >::_ConstructiblePair<_U1, _U2>() && (! std::_PCC<((! std::is_same<std::unique_ptr<ObjectBase>, _U1>::value) || (! std::is_same<std::unique_ptr<ObjectBase>, _U2>::value)), std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >::_ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&)
  explicit constexpr pair(const pair<_U1, _U2>& __p)
                     ^~~~
/usr/include/c++/6/bits/stl_pair.h:281:21: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:498:14: note:   ‘const std::unique_ptr<ObjectBase>’ is not derived from ‘const std::pair<_T1, _T2>’
       return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_pair.h:272:19: note: candidate: template<class _U1, class _U2, typename std::enable_if<(std::_PCC<((! std::is_same<std::unique_ptr<ObjectBase>, _U1>::value) || (! std::is_same<std::unique_ptr<ObjectBase>, _U2>::value)), std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >::_ConstructiblePair<_U1, _U2>() && std::_PCC<((! std::is_same<std::unique_ptr<ObjectBase>, _U1>::value) || (! std::is_same<std::unique_ptr<ObjectBase>, _U2>::value)), std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >::_ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const std::pair<_U1, _U2>&)
         constexpr pair(const pair<_U1, _U2>& __p)
                   ^~~~
/usr/include/c++/6/bits/stl_pair.h:272:19: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:498:14: note:   ‘const std::unique_ptr<ObjectBase>’ is not derived from ‘const std::pair<_T1, _T2>’
       return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_pair.h:250:26: note: candidate: template<class _U1, class _U2, typename std::enable_if<(_ConstructiblePair<_U1, _U2>() && (! _ImplicitlyConvertiblePair<_U1, _U2>())), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&)
       explicit constexpr pair(const _T1& __a, const _T2& __b)
                          ^~~~
/usr/include/c++/6/bits/stl_pair.h:250:26: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:249:38: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
                          bool>::type=false>
                                      ^~~~~
/usr/include/c++/6/bits/stl_pair.h:249:38: note: invalid template non-type parameter
/usr/include/c++/6/bits/stl_pair.h:241:17: note: candidate: template<class _U1, class _U2, typename std::enable_if<(_ConstructiblePair<_U1, _U2>() && _ImplicitlyConvertiblePair<_U1, _U2>()), bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair(const _T1&, const _T2&)
       constexpr pair(const _T1& __a, const _T2& __b)
                 ^~~~
/usr/include/c++/6/bits/stl_pair.h:241:17: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:240:38: error: no type named ‘type’ in ‘struct std::enable_if<false, bool>’
                          bool>::type=true>
                                      ^~~~
/usr/include/c++/6/bits/stl_pair.h:240:38: note: invalid template non-type parameter
/usr/include/c++/6/bits/stl_pair.h:223:26: note: candidate: template<class _U1, class _U2, typename std::enable_if<std::__and_<std::is_default_constructible<_Tp>, std::is_default_constructible<_U2>, std::__not_<std::__and_<std::__is_implicitly_default_constructible<_U1>, std::__is_implicitly_default_constructible<_U2> > > >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair()
       explicit constexpr pair()
                          ^~~~
/usr/include/c++/6/bits/stl_pair.h:223:26: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:498:14: note:   candidate expects 0 arguments, 2 provided
       return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/6/bits/stl_pair.h:210:26: note: candidate: template<class _U1, class _U2, typename std::enable_if<std::__and_<std::__is_implicitly_default_constructible<_U1>, std::__is_implicitly_default_constructible<_U2> >::value, bool>::type <anonymous> > constexpr std::pair<_T1, _T2>::pair()
       _GLIBCXX_CONSTEXPR pair()
                          ^~~~
/usr/include/c++/6/bits/stl_pair.h:210:26: note:   template argument deduction/substitution failed:
/usr/include/c++/6/bits/stl_pair.h:498:14: note:   candidate expects 0 arguments, 2 provided
       return __pair_type(std::forward<_T1>(__x), std::forward<_T2>(__y));
              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cpp: In member function ‘virtual const string& Map::ToString()’:
prog.cpp:235:15: warning: reference to local variable ‘R’ returned [-Wreturn-local-addr]
   std::string R;
               ^
In file included from /usr/include/c++/6/vector:62:0,
                 from prog.cpp:6:
/usr/include/c++/6/bits/stl_construct.h: In instantiation of ‘void std::_Construct(_T1*, _Args&& ...) [with _T1 = std::unique_ptr<ObjectBase>; _Args = {const std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >&}]’:
/usr/include/c++/6/bits/stl_uninitialized.h:75:18:   required from ‘static _ForwardIterator std::__uninitialized_copy<_TrivialValueTypes>::__uninit_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const std::unique_ptr<ObjectBase>*; _ForwardIterator = std::unique_ptr<ObjectBase>*; bool _TrivialValueTypes = false]’
/usr/include/c++/6/bits/stl_uninitialized.h:126:15:   required from ‘_ForwardIterator std::uninitialized_copy(_InputIterator, _InputIterator, _ForwardIterator) [with _InputIterator = const std::unique_ptr<ObjectBase>*; _ForwardIterator = std::unique_ptr<ObjectBase>*]’
/usr/include/c++/6/bits/stl_uninitialized.h:281:37:   required from ‘_ForwardIterator std::__uninitialized_copy_a(_InputIterator, _InputIterator, _ForwardIterator, std::allocator<_Tp>&) [with _InputIterator = const std::unique_ptr<ObjectBase>*; _ForwardIterator = std::unique_ptr<ObjectBase>*; _Tp = std::unique_ptr<ObjectBase>]’
/usr/include/c++/6/bits/stl_vector.h:1288:33:   required from ‘void std::vector<_Tp, _Alloc>::_M_range_initialize(_ForwardIterator, _ForwardIterator, std::forward_iterator_tag) [with _ForwardIterator = const std::unique_ptr<ObjectBase>*; _Tp = std::unique_ptr<ObjectBase>; _Alloc = std::allocator<std::unique_ptr<ObjectBase> >]’
/usr/include/c++/6/bits/stl_vector.h:1261:4:   required from ‘void std::vector<_Tp, _Alloc>::_M_initialize_dispatch(_InputIterator, _InputIterator, std::__false_type) [with _InputIterator = const std::unique_ptr<ObjectBase>*; _Tp = std::unique_ptr<ObjectBase>; _Alloc = std::allocator<std::unique_ptr<ObjectBase> >]’
/usr/include/c++/6/bits/stl_vector.h:406:11:   required from ‘std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = const std::unique_ptr<ObjectBase>*; <template-parameter-2-2> = void; _Tp = std::unique_ptr<ObjectBase>; _Alloc = std::allocator<std::unique_ptr<ObjectBase> >; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<std::unique_ptr<ObjectBase> >]’
prog.cpp:163:76:   required from here
/usr/include/c++/6/bits/stl_construct.h:75:7: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = ObjectBase; _Dp = std::default_delete<ObjectBase>]’
     { ::new(static_cast<void*>(__p)) _T1(std::forward<_Args>(__args)...); }
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/6/memory:81:0,
                 from prog.cpp:7:
/usr/include/c++/6/bits/unique_ptr.h:359:7: note: declared here
       unique_ptr(const unique_ptr&) = delete;
       ^~~~~~~~~~
In file included from /usr/include/c++/6/bits/stl_map.h:63:0,
                 from /usr/include/c++/6/map:61,
                 from prog.cpp:5:
/usr/include/c++/6/tuple: In instantiation of ‘std::pair<_T1, _T2>::pair(std::tuple<_Args1 ...>&, std::tuple<_Args2 ...>&, std::_Index_tuple<_Indexes1 ...>, std::_Index_tuple<_Indexes2 ...>) [with _Args1 = {const std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >&}; long unsigned int ..._Indexes1 = {0ul}; _Args2 = {}; long unsigned int ..._Indexes2 = {}; _T1 = const std::unique_ptr<ObjectBase>; _T2 = std::unique_ptr<ObjectBase>]’:
/usr/include/c++/6/tuple:1579:63:   required from ‘std::pair<_T1, _T2>::pair(std::piecewise_construct_t, std::tuple<_Args1 ...>, std::tuple<_Args2 ...>) [with _Args1 = {const std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >&}; _Args2 = {}; _T1 = const std::unique_ptr<ObjectBase>; _T2 = std::unique_ptr<ObjectBase>]’
/usr/include/c++/6/ext/new_allocator.h:120:4:   required from ‘void __gnu_cxx::new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >; _Args = {const std::piecewise_construct_t&, std::tuple<const std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >&>, std::tuple<>}; _Tp = std::_Rb_tree_node<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >]’
/usr/include/c++/6/bits/alloc_traits.h:455:4:   required from ‘static void std::allocator_traits<std::allocator<_CharT> >::construct(std::allocator_traits<std::allocator<_CharT> >::allocator_type&, _Up*, _Args&& ...) [with _Up = std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >; _Args = {const std::piecewise_construct_t&, std::tuple<const std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >&>, std::tuple<>}; _Tp = std::_Rb_tree_node<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >; std::allocator_traits<std::allocator<_CharT> >::allocator_type = std::allocator<std::_Rb_tree_node<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > > >]’
/usr/include/c++/6/bits/stl_tree.h:543:32:   required from ‘void std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_construct_node(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type, _Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >&>, std::tuple<>}; _Key = std::unique_ptr<ObjectBase>; _Val = std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >; _KeyOfValue = std::_Select1st<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >; _Compare = Map::PCmp; _Alloc = std::allocator<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >*]’
/usr/include/c++/6/bits/stl_tree.h:560:4:   required from ‘std::_Rb_tree_node<_Val>* std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_create_node(_Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >&>, std::tuple<>}; _Key = std::unique_ptr<ObjectBase>; _Val = std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >; _KeyOfValue = std::_Select1st<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >; _Compare = Map::PCmp; _Alloc = std::allocator<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_Link_type = std::_Rb_tree_node<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >*]’
/usr/include/c++/6/bits/stl_tree.h:2196:64:   required from ‘std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique(std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator, _Args&& ...) [with _Args = {const std::piecewise_construct_t&, std::tuple<const std::unique_ptr<ObjectBase, std::default_delete<ObjectBase> >&>, std::tuple<>}; _Key = std::unique_ptr<ObjectBase>; _Val = std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> >; _KeyOfValue = std::_Select1st<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >; _Compare = Map::PCmp; _Alloc = std::allocator<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator = std::_Rb_tree_iterator<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >; std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator = std::_Rb_tree_const_iterator<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >]’
/usr/include/c++/6/bits/stl_map.h:483:8:   required from ‘std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type& std::map<_Key, _Tp, _Compare, _Alloc>::operator[](const key_type&) [with _Key = std::unique_ptr<ObjectBase>; _Tp = std::unique_ptr<ObjectBase>; _Compare = Map::PCmp; _Alloc = std::allocator<std::pair<const std::unique_ptr<ObjectBase>, std::unique_ptr<ObjectBase> > >; std::map<_Key, _Tp, _Compare, _Alloc>::mapped_type = std::unique_ptr<ObjectBase>; std::map<_Key, _Tp, _Compare, _Alloc>::key_type = std::unique_ptr<ObjectBase>]’
prog.cpp:228:13:   required from here
/usr/include/c++/6/tuple:1590:70: error: use of deleted function ‘std::unique_ptr<_Tp, _Dp>::unique_ptr(const std::unique_ptr<_Tp, _Dp>&) [with _Tp = ObjectBase; _Dp = std::default_delete<ObjectBase>]’
         second(std::forward<_Args2>(std::get<_Indexes2>(__tuple2))...)
                                                                      ^
In file included from /usr/include/c++/6/memory:81:0,
                 from prog.cpp:7:
/usr/include/c++/6/bits/unique_ptr.h:359:7: note: declared here
       unique_ptr(const unique_ptr&) = delete;
       ^~~~~~~~~~
stdout
Standard output is empty