#include #include #include #include namespace boost { //====================================================== template struct cons { typedef A first_type; typedef B second_type; }; struct nil_type { }; template struct make_traits { typedef typename List::first_type Head; typedef typename List::second_type Rest; typedef typename Head::generator Gen; typedef typename Head::type Type; typedef typename make_traits::type RestTraits; typedef typename Gen::template trait type; }; struct empty_traits { }; template <> struct make_traits { typedef empty_traits type; }; //====================================================== #define BOOST_MAKE_TRAIT(NAME, TYPENAME) \ struct make_##NAME { \ template struct trait : public Base { \ typedef T TYPENAME; \ }; \ }; \ template \ struct NAME { \ typedef make_##NAME generator; \ typedef T type; \ } BOOST_MAKE_TRAIT(Value, value_type); BOOST_MAKE_TRAIT(Reference, reference); BOOST_MAKE_TRAIT(Pointer, pointer); BOOST_MAKE_TRAIT(Distance, difference_type); BOOST_MAKE_TRAIT(Category, iterator_category); struct default_argument; struct make_default { template struct trait { typedef T difference_type; typedef T pointer; typedef T reference; typedef T value_type; typedef T iterator_category; }; }; struct default_argument { typedef make_default generator; typedef default_argument type; }; template struct is_default { enum { value = false }; }; struct is_default { enum { value = true }; }; template class iterator_adaptor_generator { typedef cons > > > > ArgList; typedef make_traits::type traits; typedef typename traits::value_type Value; typedef typename traits::difference_type Distance_; typedef typename traits::reference Reference_; typedef typename traits::pointer Pointer_; typedef typename traits::iterator_category Category_; typedef boost::detail::iterator_traits base_traits; typedef boost::detail::iterator_defaults default_traits; typedef typename ct_if< is_default::value, typename default_traits::reference, Reference_>::type Reference; typedef typename ct_if< is_default::value, typename default_traits::pointer, Pointer_>::type Pointer; typedef typename ct_if< is_default::value, typename base_traits::iterator_category, Category_>::type Category; typedef typename ct_if< is_default::value, typename base_traits::difference_type, Distance_>::type Distance; public: typedef iterator_adaptor type; }; } // namespace boost