#ifndef SPROUT_RANGE_ADAPTOR_JOINTED_HPP #define SPROUT_RANGE_ADAPTOR_JOINTED_HPP #include #include #include #include #include #include #include #include #include #include #include #include namespace sprout { namespace adaptors { // // jointed_range // template class jointed_range : public sprout::range::range_container< sprout::joint_iterator< typename sprout::container_traits::iterator, typename sprout::container_traits::iterator > > , public sprout::detail::container_nosy_static_size , public sprout::detail::container_nosy_fixed_size { public: typedef LRange range_type; typedef RRange range2_type; typedef sprout::range::range_container< sprout::joint_iterator< typename sprout::container_traits::iterator, typename sprout::container_traits::iterator > > base_type; typedef typename base_type::iterator iterator; public: jointed_range() = default; jointed_range(jointed_range const&) = default; SPROUT_CONSTEXPR jointed_range(range_type& range1, range2_type& range2) : base_type( iterator(sprout::begin(range1), sprout::end(range1), sprout::begin(range2), sprout::begin(range2)), iterator(sprout::end(range1), sprout::end(range1), sprout::begin(range2), sprout::end(range2)) ) {} }; // // joint_holder // template class joint_holder { public: typedef RRange range2_type; private: sprout::value_holder range_; public: joint_holder() = default; joint_holder(joint_holder const&) = default; explicit SPROUT_CONSTEXPR joint_holder(range2_type& range) : range_(range) {} SPROUT_CONSTEXPR range2_type& range() const { return range_; } }; // // jointed_forwarder // class jointed_forwarder { public: template SPROUT_CONSTEXPR sprout::adaptors::joint_holder< typename std::remove_reference::type>::type > operator()(RRange&& range) { return sprout::adaptors::joint_holder< typename std::remove_reference::type>::type >( sprout::lvalue_forward(range) ); } }; // // jointed // namespace { SPROUT_STATIC_CONSTEXPR sprout::adaptors::jointed_forwarder jointed{}; } // anonymous-namespace // // operator| // template inline SPROUT_CONSTEXPR sprout::adaptors::jointed_range< typename std::remove_reference::type>::type, RRange > operator|(LRange&& lhs, sprout::adaptors::joint_holder const& rhs) { return sprout::adaptors::jointed_range< typename std::remove_reference::type>::type, RRange >( sprout::lvalue_forward(lhs), rhs.range() ); } } // 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_JOINTED_HPP