fork download
  1. #include <boost/foreach.hpp>
  2. #include <boost/iterator/iterator_facade.hpp>
  3. #include <iterator>
  4.  
  5. namespace math {
  6. class IntegerVector
  7. {
  8. public:
  9. IntegerVector(int, int, int) {};
  10.  
  11. };
  12.  
  13. class IntegerVectorRange
  14. {
  15. private:
  16. public:
  17. IntegerVectorRange(IntegerVector const& ) {};
  18.  
  19. struct const_iterator : public boost::iterator_facade<const_iterator,
  20. IntegerVector const,
  21. std::forward_iterator_tag>
  22. {
  23. bool equal(const_iterator const& ) const {return true;}
  24. void increment() {}
  25. IntegerVector const& dereference() const {return *static_cast<IntegerVector*>(0);}
  26. };
  27.  
  28. const_iterator begin() const {return const_iterator();}
  29. const_iterator end() const {return const_iterator();}
  30. };
  31. }
  32.  
  33. template <class T1>
  34. T1 fun()
  35. {
  36. T1 result(0.0);
  37.  
  38. BOOST_FOREACH(const math::IntegerVector &v, math::IntegerVectorRange(math::IntegerVector(2 , 2 ,2)))
  39. {
  40. // Do stuff.
  41. }
  42.  
  43. return result;
  44. }
  45.  
  46. int main()
  47. {
  48. fun<int>();
  49. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/include/boost/range/mutable_iterator.hpp: In instantiation of ‘boost::range_mutable_iterator<math::IntegerVectorRange>’:
/usr/include/boost/mpl/eval_if.hpp:38:   instantiated from ‘boost::mpl::eval_if<mpl_::bool_<false>, boost::range_const_iterator<math::IntegerVectorRange>, boost::range_mutable_iterator<math::IntegerVectorRange> >’
/usr/include/boost/foreach.hpp:363:   instantiated from ‘boost::foreach_detail_::foreach_iterator<math::IntegerVectorRange, mpl_::bool_<false> >’
prog.cpp:38:   instantiated from here
/usr/include/boost/range/mutable_iterator.hpp:37: error: no type named ‘iterator’ in ‘class math::IntegerVectorRange’
prog.cpp: In function ‘T1 fun()’:
prog.cpp:38: error: no matching function for call to ‘begin(const boost::foreach_detail_::auto_any_base&, boost::foreach_detail_::type2type<math::IntegerVectorRange, mpl_::bool_<false> >*, boost::mpl::or_<boost::mpl::and_<boost::mpl::not_<boost::is_array<math::IntegerVectorRange> >, mpl_::bool_<false>, mpl_::bool_<true>, mpl_::bool_<true>, mpl_::bool_<true> >, boost::mpl::and_<boost::mpl::not_<boost::foreach::is_noncopyable<math::IntegerVectorRange> >, boost::foreach::is_lightweight_proxy<math::IntegerVectorRange>, mpl_::bool_<true>, mpl_::bool_<true>, mpl_::bool_<true> >, mpl_::bool_<false>, mpl_::bool_<false>, mpl_::bool_<false> >*)’
prog.cpp:38: error: no matching function for call to ‘end(const boost::foreach_detail_::auto_any_base&, boost::foreach_detail_::type2type<math::IntegerVectorRange, mpl_::bool_<false> >*, boost::mpl::or_<boost::mpl::and_<boost::mpl::not_<boost::is_array<math::IntegerVectorRange> >, mpl_::bool_<false>, mpl_::bool_<true>, mpl_::bool_<true>, mpl_::bool_<true> >, boost::mpl::and_<boost::mpl::not_<boost::foreach::is_noncopyable<math::IntegerVectorRange> >, boost::foreach::is_lightweight_proxy<math::IntegerVectorRange>, mpl_::bool_<true>, mpl_::bool_<true>, mpl_::bool_<true> >, mpl_::bool_<false>, mpl_::bool_<false>, mpl_::bool_<false> >*)’
prog.cpp:38: error: no matching function for call to ‘deref(const boost::foreach_detail_::auto_any_base&, boost::foreach_detail_::type2type<math::IntegerVectorRange, mpl_::bool_<false> >*)’
prog.cpp: In function ‘T1 fun() [with T1 = int]’:
prog.cpp:48:   instantiated from here
prog.cpp:38: warning: unused variable ‘v’
stdout
Standard output is empty