/*============================================================================= Copyright (c) 2011-2019 Bolero MURAKAMI https://github.com/bolero-MURAKAMI/Sprout Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) =============================================================================*/ #ifndef SPROUT_RANGE_ADAPTOR_SIZED_HPP #define SPROUT_RANGE_ADAPTOR_SIZED_HPP #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace adaptors { // // sized_range // template::size_type Size> class sized_range : public sprout::adaptors::detail::sized_range_default { public: typedef sprout::adaptors::detail::sized_range_default base_type; typedef typename base_type::range_type range_type; typedef typename base_type::size_type size_type; public: SPROUT_CONSTEXPR sized_range() SPROUT_DEFAULTED_DEFAULT_CONSTRUCTOR_DECL sized_range(sized_range const&) = default; explicit SPROUT_CONSTEXPR sized_range(range_type& range) : base_type( sprout::begin(range), base_type::static_size < static_cast(sprout::size(range)) ? sprout::next(sprout::begin(range), base_type::static_size) : sprout::end(range) ) {} }; // // size_holder // template class size_holder : public sprout::integral_constant {}; // // sized // template inline SPROUT_CONSTEXPR sprout::adaptors::size_holder sized() { return sprout::adaptors::size_holder(); } // // operator| // template inline SPROUT_CONSTEXPR sprout::adaptors::sized_range< typename std::remove_reference::type>::type, Size > operator|(Range&& lhs, sprout::adaptors::size_holder const&) { return sprout::adaptors::sized_range< typename std::remove_reference::type>::type, Size >( sprout::lvalue_forward(lhs) ); } } // namespace adaptors // // container_construct_traits // template::size_type Size> struct container_construct_traits > : public sprout::container_construct_traits::base_type> {}; } // namespace sprout #endif // #ifndef SPROUT_RANGE_ADAPTOR_SIZED_HPP