#ifndef SPROUT_RANGE_ADAPTOR_DROPPED_HPP #define SPROUT_RANGE_ADAPTOR_DROPPED_HPP #include #include #include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT namespace sprout { namespace adaptors { // // drop_holder // template class drop_holder { public: typedef Difference difference_type; private: difference_type distance_; public: explicit SPROUT_CONSTEXPR drop_holder(difference_type distance) : distance_(distance) {} SPROUT_CONSTEXPR difference_type const& distance() const { return distance_; } }; // // dropped_forwarder // class dropped_forwarder { public: template SPROUT_CONSTEXPR sprout::adaptors::drop_holder operator()(Difference distance) { return sprout::adaptors::drop_holder(distance); } }; // // dropped // namespace { SPROUT_STATIC_CONSTEXPR sprout::adaptors::dropped_forwarder dropped{}; } // anonymous-namespace // // operator| // template inline SPROUT_CONSTEXPR sprout::range::range_container< typename sprout::container_traits::type>::type>::iterator > operator|(Range&& lhs, sprout::adaptors::drop_holder const& rhs) { typedef typename sprout::container_traits< typename std::remove_reference::type>::type >::difference_type difference_type; return sprout::range::range_container< typename sprout::container_traits::type>::type>::iterator >( sprout::next( sprout::begin(sprout::lvalue_forward(lhs)), NS_SSCRISK_CEL_OR_SPROUT::min(rhs.distance(), sprout::size(sprout::lvalue_forward(lhs))) ), sprout::end(sprout::lvalue_forward(lhs)) ); } } // namespace adaptors } // namespace sprout #endif // #ifndef SPROUT_RANGE_ADAPTOR_DROPPED_HPP