Advertisement
Guest User

Untitled

a guest
Sep 12th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.01 KB | None | 0 0
  1. struct wrapper
  2. {
  3.     struct iterator : std::iterator<std::forward_iterator_tag, ObservationReport>
  4.     {
  5.         iterator(ObservationReportList* p, int i) : pnt_(p), i_(i) {}
  6.  
  7.         ObservationReport& operator*() {
  8.             return (*pnt_)[i_];
  9.         }
  10.  
  11.         iterator& operator++() {
  12.             ++i_;
  13.             return *this;
  14.         }
  15.  
  16.         bool operator==(const iterator& r) const {
  17.             return i_ == r.i_;
  18.         }
  19.         bool operator!=(const iterator& r) const {
  20.             return i_ != r.i_;
  21.         }
  22.  
  23.         ObservationReportList* pnt_;
  24.         int i_;
  25.     };
  26.  
  27.     wrapper(ObservationReportList & n)
  28.     : begin_( boost::addressof(n), 0 )
  29.     , end_( boost::addressof(n), n.length() )
  30.     {}
  31.  
  32.     iterator begin() { return begin_; }
  33.     iterator end() { return end_; }
  34.  
  35.     iterator begin_, end_;
  36. };
  37.  
  38. // usage
  39.  
  40.   ObservationReportList reportList;
  41.   // filling reportList
  42.   BOOST_FOREACH(ObservationReport o,  wrapper(reportList))
  43.   {
  44.   }
  45.  
  46.  
  47.  
  48. //gcc error
  49.  
  50. In file included from /usr/include/boost159/boost/foreach.hpp:71:0,
  51.                  from test/src/MessageFillerTest.cpp:18:
  52. /usr/include/boost159/boost/mpl/eval_if.hpp: In instantiation of ‘struct boost::mpl::eval_if<mpl_::bool_<true>, boost::range_const_iterator<wrapper, void>, boost::range_mutable_iterator<wrapper, void> >:
  53. /usr/include/boost159/boost/foreach.hpp:359:13:   required from ‘struct boost::foreach_detail_::foreach_iterator<wrapper, mpl_::bool_<true> >
  54. /usr/include/boost159/boost/foreach.hpp:679:1:   required by substitution of ‘template<class T> boost::foreach_detail_::auto_any<typename boost::foreach_detail_::foreach_iterator<T, mpl_::bool_<true> >::type> boost::foreach_detail_::begin(
  55. boost::foreach_detail_::auto_any_t, boost::foreach_detail_::type2type<T, mpl_::bool_<true> >*, bool*) [with T = wrapper]
  56. test/src/MessageFillerTest.cpp:206:3:   required from here
  57. /usr/include/boost159/boost/mpl/eval_if.hpp:38:31: error: no type named ‘type’ in ‘boost::mpl::eval_if<mpl_::bool_<true>, boost::range_const_iterator<wrapper, void>, boost::range_mutable_iterator<wrapper, void> >::f_ {aka struct boost::ran
  58. ge_const_iterator<wrapper, void>}
  59.      typedef typename f_::type type;
  60.                                ^
  61. In file included from test/src/MessageFillerTest.cpp:18:0:
  62. test/src/MessageFillerTest.cpp: In member function ‘virtual void MessageFiller_XXX_Test::TestBody():
  63. /usr/include/boost159/boost/foreach.hpp:1020:39: error: no matching function for call to ‘begin(const boost::foreach_detail_::auto_any_base&, boost::foreach_detail_::type2type<wrapper, mpl_::bool_<true> >*, bool*)
  64.        , BOOST_FOREACH_SHOULD_COPY(COL))
  65.                                        ^
  66. /usr/include/boost159/boost/foreach.hpp:1101:77: note: in expansion of macro ‘BOOST_FOREACH_BEGIN’
  67.      if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL)) {} else     \
  68.                                                                              ^
  69. test/src/MessageFillerTest.cpp:206:3: note: in expansion of macro ‘BOOST_FOREACH’
  70.    BOOST_FOREACH(ObservationReport o,  wrapper(reportList))
  71.    ^
  72. /usr/include/boost159/boost/foreach.hpp:660:1: note: candidate: template<class T, class C> boost::foreach_detail_::auto_any<typename boost::foreach_detail_::foreach_iterator<T, C>::type> boost::foreach_detail_::begin(boost::foreach_detail_
  73. ::auto_any_t, boost::foreach_detail_::type2type<T, C>*, mpl_::true_*)
  74.  begin(auto_any_t col, type2type<T, C> *, boost::mpl::true_ *) // rvalue
  75.  ^
  76. /usr/include/boost159/boost/foreach.hpp:660:1: note:   template argument deduction/substitution failed:
  77. /usr/include/boost159/boost/foreach.hpp:964:46: note:   cannot convert ‘boost::foreach_detail_::should_copy_impl(((mpl_::bool_<false>*)0u), ((mpl_::bool_<false>*)0u), (& _foreach_is_rvalue206))(type ‘bool*) to type ‘mpl_::true_* {aka mp
  78. l_::bool_<true>*}
  79.      (boost::foreach_detail_::should_copy_impl(                                                  \
  80.                                               ^
  81. /usr/include/boost159/boost/foreach.hpp:1020:9: note: in expansion of macro ‘BOOST_FOREACH_SHOULD_COPY’
  82.        , BOOST_FOREACH_SHOULD_COPY(COL))
  83.          ^
  84. /usr/include/boost159/boost/foreach.hpp:1101:77: note: in expansion of macro ‘BOOST_FOREACH_BEGIN’
  85.      if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL)) {} else     \
  86.                                                                              ^
  87. test/src/MessageFillerTest.cpp:206:3: note: in expansion of macro ‘BOOST_FOREACH’
  88.    BOOST_FOREACH(ObservationReport o,  wrapper(reportList))
  89.    ^
  90. /usr/include/boost159/boost/foreach.hpp:668:1: note: candidate: template<class T, class C> boost::foreach_detail_::auto_any<typename boost::foreach_detail_::foreach_iterator<T, C>::type> boost::foreach_detail_::begin(boost::foreach_detail_
  91. ::auto_any_t, boost::foreach_detail_::type2type<T, C>*, mpl_::false_*)
  92.  begin(auto_any_t col, type2type<T, C> *, boost::mpl::false_ *) // lvalue
  93.  ^
  94. /usr/include/boost159/boost/foreach.hpp:668:1: note:   template argument deduction/substitution failed:
  95. /usr/include/boost159/boost/foreach.hpp:964:46: note:   cannot convert ‘boost::foreach_detail_::should_copy_impl(((mpl_::bool_<false>*)0u), ((mpl_::bool_<false>*)0u), (& _foreach_is_rvalue206))(type ‘bool*) to type ‘mpl_::false_* {aka m
  96. pl_::bool_<false>*}
  97.      (boost::foreach_detail_::should_copy_impl(                                                  \
  98.                                               ^
  99. /usr/include/boost159/boost/foreach.hpp:1020:9: note: in expansion of macro ‘BOOST_FOREACH_SHOULD_COPY’
  100.        , BOOST_FOREACH_SHOULD_COPY(COL))
  101.          ^
  102. /usr/include/boost159/boost/foreach.hpp:1101:77: note: in expansion of macro ‘BOOST_FOREACH_BEGIN’
  103.      if (boost::foreach_detail_::auto_any_t BOOST_FOREACH_ID(_foreach_cur) = BOOST_FOREACH_BEGIN(COL)) {} else     \
  104.                                                                              ^
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement