#ifndef SPROUT_RANGE_ADAPTOR_BLANKED_HPP #define SPROUT_RANGE_ADAPTOR_BLANKED_HPP #include #include #include #include #include #include #include #include #include #include #include #include HDR_ALGORITHM_SSCRISK_CEL_OR_SPROUT namespace sprout { // // blank_t // struct blank_t {}; namespace adaptors { // // blanked_range // template class blanked_range : public sprout::range::range_container< sprout::value_iterator > , public sprout::detail::container_nosy_static_size , public sprout::detail::container_nosy_fixed_size { public: typedef Range range_type; typedef sprout::range::range_container< sprout::value_iterator > base_type; typedef typename base_type::iterator iterator; typedef typename base_type::value_type value_type; typedef typename base_type::difference_type difference_type; typedef typename base_type::size_type size_type; public: blanked_range() = default; blanked_range(blanked_range const&) = default; explicit SPROUT_CONSTEXPR blanked_range(range_type& range) : base_type( iterator(value_type(), sprout::size(range)), iterator(value_type(), 0) ) {} SPROUT_CONSTEXPR blanked_range( range_type& range, difference_type n ) : base_type( iterator(value_type(), static_cast(NS_SSCRISK_CEL_OR_SPROUT::min(n, sprout::size(range)))), iterator(value_type(), 0) ) {} SPROUT_CONSTEXPR blanked_range( range_type& range, difference_type n, value_type const& value ) : base_type( iterator(value, static_cast(NS_SSCRISK_CEL_OR_SPROUT::min(n, sprout::size(range)))), iterator(value, 0) ) {} }; template class blanked_range : public sprout::range::range_container< sprout::value_iterator > { public: typedef sprout::range::range_container< sprout::value_iterator > base_type; typedef typename base_type::iterator iterator; typedef typename base_type::value_type value_type; typedef typename base_type::difference_type difference_type; public: SPROUT_CONSTEXPR blanked_range() : base_type( iterator(value_type()), iterator(value_type(), 0) ) {} blanked_range(blanked_range const&) = default; explicit SPROUT_CONSTEXPR blanked_range(difference_type n) : base_type( iterator(value_type(), n), iterator(value_type(), 0) ) {} SPROUT_CONSTEXPR blanked_range( difference_type n, value_type const& value ) : base_type( iterator(value, n), iterator(value, 0) ) {} }; // // blanked_forwarder // class blanked_forwarder { public: SPROUT_CONSTEXPR sprout::adaptors::blanked_range<> operator()() const { return sprout::adaptors::blanked_range<>(); } template SPROUT_CONSTEXPR sprout::adaptors::blanked_range<> operator()(Difference n) const { return sprout::adaptors::blanked_range<>(n); } template SPROUT_CONSTEXPR sprout::adaptors::blanked_range operator()(Difference n, T const& value) const { return sprout::adaptors::blanked_range(n, value); } }; // // blanked // namespace { SPROUT_STATIC_CONSTEXPR sprout::adaptors::blanked_forwarder blanked{}; } // anonymous-namespace // // operator| // template inline SPROUT_CONSTEXPR sprout::adaptors::blanked_range< T, typename std::remove_reference::type>::type > operator|(Range&& lhs, sprout::adaptors::blanked_range const& rhs) { return sprout::adaptors::blanked_range< T, typename std::remove_reference::type>::type >( sprout::lvalue_forward(lhs), sprout::size(rhs), !sprout::empty(rhs) ? *rhs.begin() : typename sprout::container_traits >::value_type() ); } } // namespace adaptors // // container_construct_traits // template struct container_construct_traits > { public: typedef typename sprout::container_construct_traits::copied_type copied_type; public: template static SPROUT_CONSTEXPR copied_type deep_copy(Cont&& cont) { return sprout::range::fixed::copy(sprout::forward(cont), sprout::pit()); } template static SPROUT_CONSTEXPR copied_type make(Args&&... args) { return sprout::make(sprout::forward(args)...); } template static SPROUT_CONSTEXPR copied_type remake( Cont&& cont, typename sprout::container_traits >::difference_type size, Args&&... args ) { return sprout::remake(sprout::forward(cont), size, sprout::forward(args)...); } }; } // namespace sprout #endif // #ifndef SPROUT_RANGE_ADAPTOR_BLANKED_HPP