#ifndef INCLUDE_GUARD_TAIL_HH #define INCLUDE_GUARD_TAIL_HH #include #include #include #include #include #include #include #include enum EmptyRange { }; template struct tail_range : boost::iterator_range::type> { public: typedef typename boost::range_result_iterator::type iterator; typedef boost::iterator_range base_range; BOOST_CLASS_REQUIRE(iterator, boost_concepts, SinglePassIteratorConcept); explicit tail_range(SinglePassRange &range) : base_range(skip_front(range), boost::end(range)) { } private: static iterator skip_front(SinglePassRange &range) { if (boost::empty(range)) throw EmptyRange(); return ++boost::begin(range); } }; template tail_range make_tail_range(SinglePassRange &range) { return tail_range(range); } template tail_range make_tail_range(SinglePassRange const &range) { return tail_range(range); } namespace detail { struct tail_range_adaptor { template struct apply { BOOST_STATIC_ASSERT((boost::tuples::length::value == 0)); typedef tail_range type; }; template static typename apply::type make_range(SinglePassRange &range, Args) { return make_tail_range(range); } }; } // namespace detail boost::range_adaptor const tail; #endif // !INCLUDE_GUARD_TAIL_HH