fork download
  1. #include <iostream>
  2. #include <boost/assign.hpp>
  3. #include <boost/assign/list_of.hpp>
  4. #include <tuple>
  5. using namespace std;
  6. using namespace boost::assign;
  7.  
  8. int main() {
  9.  
  10. class NodeInfo
  11. {
  12. public:
  13. NodeInfo (int Parent, int childLeft, int childRight) :
  14. m_parent (Parent), m_childLeft(childLeft), m_childRight(childRight)
  15. {
  16.  
  17. }
  18. private:
  19. int m_parent;
  20. int m_childLeft;
  21. int m_childRight;
  22. };
  23. typedef std::vector<NodeInfo> MyData1;
  24. MyData1 expData = list_of(NodeInfo(1,2,3)) (NodeInfo(3,4,5));
  25.  
  26. typedef std::tuple<int , std::vector<NodeInfo>> MyData2;
  27. MyData2 expData21 = std::make_tuple(10 , expData);
  28.  
  29. MyData2 expData22 = std::make_tuple(10 , list_of(NodeInfo(1,2,3)) (NodeInfo(3,4,5)) );
  30. // I would have really liked the following:
  31. // error:
  32. //MyData2 expData22 = std::make_tuple(10 ,
  33. //list_of(NodeInfo(1,2,3)) (NodeInfo(3,4,5)) );
  34.  
  35.  
  36. return 0;
  37. }
Compilation error #stdin compilation error #stdout 0s 3228KB
stdin
Standard input is empty
compilation info
In file included from /usr/include/c++/4.9/bits/stl_map.h:63:0,
                 from /usr/include/c++/4.9/map:61,
                 from /usr/include/boost/assign/std/map.hpp:21,
                 from /usr/include/boost/assign/std.hpp:25,
                 from /usr/include/boost/assign.hpp:19,
                 from prog.cpp:2:
/usr/include/c++/4.9/tuple: In instantiation of 'constexpr std::_Head_base<_Idx, _Head, false>::_Head_base(_UHead&&) [with _UHead = boost::assign_detail::generic_list<main()::NodeInfo>; unsigned int _Idx = 1u; _Head = std::vector<main()::NodeInfo>]':
/usr/include/c++/4.9/tuple:285:57:   recursively required from 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(std::_Tuple_impl<_Idx, _UHead, _UTails ...>&&) [with _UHead = boost::assign_detail::generic_list<main()::NodeInfo>; _UTails = {}; unsigned int _Idx = 1u; _Head = std::vector<main()::NodeInfo>; _Tail = {}]'
/usr/include/c++/4.9/tuple:285:57:   required from 'constexpr std::_Tuple_impl<_Idx, _Head, _Tail ...>::_Tuple_impl(std::_Tuple_impl<_Idx, _UHead, _UTails ...>&&) [with _UHead = int; _UTails = {boost::assign_detail::generic_list<main()::NodeInfo>}; unsigned int _Idx = 0u; _Head = int; _Tail = {std::vector<main()::NodeInfo, std::allocator<main()::NodeInfo> >}]'
/usr/include/c++/4.9/tuple:556:60:   required from 'constexpr std::tuple<_T1, _T2>::tuple(std::tuple<_U1, _U2>&&) [with _U1 = int; _U2 = boost::assign_detail::generic_list<main()::NodeInfo>; <template-parameter-2-3> = void; _T1 = int; _T2 = std::vector<main()::NodeInfo>]'
prog.cpp:29:86:   required from here
/usr/include/c++/4.9/tuple:142:42: error: call of overloaded 'vector(boost::assign_detail::generic_list<main()::NodeInfo>)' is ambiguous
  : _M_head_impl(std::forward<_UHead>(__h)) { }
                                          ^
/usr/include/c++/4.9/tuple:142:42: note: candidates are:
In file included from /usr/include/c++/4.9/vector:64:0,
                 from /usr/include/boost/assign/std/vector.hpp:20,
                 from /usr/include/boost/assign/std.hpp:18,
                 from /usr/include/boost/assign.hpp:19,
                 from prog.cpp:2:
/usr/include/c++/4.9/bits/stl_vector.h:373:7: note: std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = main()::NodeInfo; _Alloc = std::allocator<main()::NodeInfo>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<main()::NodeInfo>]
       vector(initializer_list<value_type> __l,
       ^
/usr/include/c++/4.9/bits/stl_vector.h:335:7: note: std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = main()::NodeInfo; _Alloc = std::allocator<main()::NodeInfo>]
       vector(vector&& __x) noexcept
       ^
/usr/include/c++/4.9/bits/stl_vector.h:318:7: note: std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = main()::NodeInfo; _Alloc = std::allocator<main()::NodeInfo>]
       vector(const vector& __x)
       ^
/usr/include/c++/4.9/bits/stl_vector.h:277:7: note: std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = main()::NodeInfo; _Alloc = std::allocator<main()::NodeInfo>; std::vector<_Tp, _Alloc>::size_type = unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<main()::NodeInfo>]
       vector(size_type __n, const allocator_type& __a = allocator_type())
       ^
/usr/include/c++/4.9/bits/stl_vector.h:264:7: note: std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = main()::NodeInfo; _Alloc = std::allocator<main()::NodeInfo>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<main()::NodeInfo>]
       vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
       ^
stdout
Standard output is empty