Index: const_iterator.hpp =================================================================== --- const_iterator.hpp (revision 50412) +++ const_iterator.hpp (working copy) @@ -21,6 +21,7 @@ #include #else +#include #include #include #include @@ -31,11 +32,13 @@ // default ////////////////////////////////////////////////////////////////////////// - template< typename C > - struct range_const_iterator - { - typedef BOOST_DEDUCED_TYPENAME C::const_iterator type; - }; + namespace detail { + BOOST_EXTRACT_OPTIONAL_TYPE( const_iterator ) + } + + template< typename C > + struct range_const_iterator: detail::extract_const_iterator + {}; ////////////////////////////////////////////////////////////////////////// // pair Index: detail/extract_optional_type.hpp =================================================================== --- detail/extract_optional_type.hpp (revision 0) +++ detail/extract_optional_type.hpp (revision 0) @@ -0,0 +1,29 @@ +#ifndef BOOST_EXTRACT_OPTIONAL_TYPE_HPP +#define BOOST_EXTRACT_OPTIONAL_TYPE_HPP + +#if defined(_MSC_VER) && (_MSC_VER >= 1200) +# pragma once +#endif + +#include + +namespace boost { + namespace detail { + template< typename T > struct exists { typedef void type; }; + } +} + +// Defines extract_some_typedef which exposes T::some_typedef as extract_some_typedef::type +// if T::some_typedef exists. Otherwise extract_some_typedef is empty. +#define BOOST_EXTRACT_OPTIONAL_TYPE( some_typedef ) \ + template< typename C, typename Enable=void > \ + struct extract_ ## some_typedef \ + {}; \ + template< typename C > \ + struct extract_ ## some_typedef< C \ + , BOOST_DEDUCED_TYPENAME boost::detail::exists< BOOST_DEDUCED_TYPENAME C::some_typedef >::type \ + > { \ + typedef BOOST_DEDUCED_TYPENAME C::some_typedef type; \ + }; + +#endif \ No newline at end of file Index: mutable_iterator.hpp =================================================================== --- mutable_iterator.hpp (revision 50412) +++ mutable_iterator.hpp (working copy) @@ -21,6 +21,7 @@ #include #else +#include #include #include #include @@ -31,11 +32,13 @@ // default ////////////////////////////////////////////////////////////////////////// - template< typename C > - struct range_mutable_iterator - { - typedef BOOST_DEDUCED_TYPENAME C::iterator type; - }; + namespace detail { + BOOST_EXTRACT_OPTIONAL_TYPE( iterator ) + } + + template< typename C > + struct range_mutable_iterator: detail::extract_iterator + {}; ////////////////////////////////////////////////////////////////////////// // pair