Chris@16: // Copyright Neil Groves 2010. Use, modification and Chris@16: // distribution is subject to the Boost Software License, Version Chris@16: // 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: // Chris@16: // Chris@16: // For more information, see http://www.boost.org/libs/range/ Chris@16: // Chris@16: #ifndef BOOST_RANGE_ANY_RANGE_HPP_INCLUDED Chris@16: #define BOOST_RANGE_ANY_RANGE_HPP_INCLUDED Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: namespace range_detail Chris@16: { Chris@16: // If T is use_default, return the result of Default, otherwise Chris@16: // return T. Chris@16: // Chris@16: // This is an implementation artifact used to pick intelligent default Chris@16: // values when the user specified boost::use_default as a template Chris@16: // parameter. Chris@16: template< Chris@16: class T, Chris@16: class Default Chris@16: > Chris@16: struct any_range_default_help Chris@16: : mpl::eval_if< Chris@16: is_same Chris@16: , Default Chris@16: , mpl::identity Chris@16: > Chris@16: { Chris@16: }; Chris@16: Chris@16: template< Chris@16: class WrappedRange Chris@16: , class Value Chris@16: , class Reference Chris@16: > Chris@16: struct any_range_value_type Chris@16: { Chris@16: # ifdef BOOST_ITERATOR_REF_CONSTNESS_KILLS_WRITABILITY Chris@16: typedef typename any_range_default_help< Chris@16: Value Chris@16: , mpl::eval_if< Chris@16: is_same Chris@16: , range_value< Chris@16: typename remove_const Chris@16: ::type> Chris@16: , remove_reference Chris@16: > Chris@16: >::type type; Chris@16: # else Chris@16: typedef typename any_range_default_help< Chris@16: Value Chris@16: , range_value< Chris@16: typename remove_const Chris@16: ::type> Chris@16: >::type type; Chris@16: # endif Chris@16: }; Chris@16: Chris@16: template< Chris@16: class Value Chris@16: , class Traversal Chris@101: , class Reference = Value& Chris@101: , class Difference = std::ptrdiff_t Chris@16: , class Buffer = use_default Chris@16: > Chris@16: class any_range Chris@16: : public iterator_range< Chris@16: any_iterator< Chris@16: Value Chris@16: , Traversal Chris@16: , Reference Chris@16: , Difference Chris@16: , typename any_range_default_help< Chris@16: Buffer Chris@16: , mpl::identity Chris@16: >::type Chris@16: > Chris@16: > Chris@16: { Chris@16: typedef iterator_range< Chris@16: any_iterator< Chris@16: Value Chris@16: , Traversal Chris@16: , Reference Chris@16: , Difference Chris@16: , typename any_range_default_help< Chris@16: Buffer Chris@16: , mpl::identity Chris@16: >::type Chris@16: > Chris@16: > base_type; Chris@16: Chris@16: struct enabler {}; Chris@16: struct disabler {}; Chris@16: public: Chris@16: any_range() Chris@16: { Chris@16: } Chris@16: Chris@16: any_range(const any_range& other) Chris@16: : base_type(other) Chris@16: { Chris@16: } Chris@16: Chris@16: template Chris@16: any_range(WrappedRange& wrapped_range) Chris@16: : base_type(boost::begin(wrapped_range), Chris@16: boost::end(wrapped_range)) Chris@16: { Chris@16: } Chris@16: Chris@16: template Chris@16: any_range(const WrappedRange& wrapped_range) Chris@16: : base_type(boost::begin(wrapped_range), Chris@16: boost::end(wrapped_range)) Chris@16: { Chris@16: } Chris@16: Chris@16: template< Chris@16: class OtherValue Chris@16: , class OtherTraversal Chris@16: , class OtherReference Chris@16: , class OtherDifference Chris@16: > Chris@16: any_range(const any_range< Chris@16: OtherValue Chris@16: , OtherTraversal Chris@16: , OtherReference Chris@16: , OtherDifference Chris@16: , Buffer Chris@16: >& other) Chris@16: : base_type(boost::begin(other), boost::end(other)) Chris@16: { Chris@16: } Chris@16: Chris@16: template Chris@16: any_range(Iterator first, Iterator last) Chris@16: : base_type(first, last) Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: template< Chris@16: class WrappedRange Chris@16: , class Value = use_default Chris@16: , class Traversal = use_default Chris@16: , class Reference = use_default Chris@16: , class Difference = use_default Chris@16: , class Buffer = use_default Chris@16: > Chris@16: struct any_range_type_generator Chris@16: { Chris@16: BOOST_RANGE_CONCEPT_ASSERT(( SinglePassRangeConcept )); Chris@16: typedef any_range< Chris@16: typename any_range_value_type< Chris@16: WrappedRange Chris@16: , Value Chris@16: , typename any_range_default_help< Chris@16: Reference Chris@16: , range_reference Chris@16: >::type Chris@16: >::type Chris@16: , typename any_range_default_help< Chris@16: Traversal Chris@16: , iterator_traversal< Chris@16: typename range_iterator::type Chris@16: > Chris@16: >::type Chris@16: , typename any_range_default_help< Chris@16: Reference Chris@16: , range_reference Chris@16: >::type Chris@16: , typename any_range_default_help< Chris@16: Difference Chris@16: , range_difference Chris@16: >::type Chris@16: , typename any_range_default_help< Chris@16: Buffer Chris@16: , mpl::identity Chris@16: >::type Chris@16: > type; Chris@16: }; Chris@16: } // namespace range_detail Chris@16: Chris@16: using range_detail::any_range; Chris@16: using range_detail::any_range_type_generator; Chris@16: } // namespace boost Chris@16: Chris@16: #endif // include guard