From a47b8664f711d9dbd1e478bfa1873535cdd8a5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorsten=20J=C3=B8rgen=20Ottosen?= Date: Fri, 9 Sep 2005 16:11:29 +0000 Subject: [PATCH] simplified metafunctions interface [SVN r30889] --- include/boost/range/difference_type.hpp | 24 ++++++++++--- include/boost/range/size_type.hpp | 48 +++++++++++++++++++++++++ include/boost/range/value_type.hpp | 24 ++++++++++--- 3 files changed, 86 insertions(+), 10 deletions(-) diff --git a/include/boost/range/difference_type.hpp b/include/boost/range/difference_type.hpp index 1aa3246..e498ebb 100755 --- a/include/boost/range/difference_type.hpp +++ b/include/boost/range/difference_type.hpp @@ -16,12 +16,25 @@ #endif #include - -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -#include -#else - +#include #include + +namespace boost +{ + template< class T > + struct range_difference + { + typedef BOOST_DEDUCED_TYPENAME iterator_difference< + BOOST_DEDUCED_TYPENAME range_const_iterator::type >::type + type; + }; +} + +//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +//#include +//#else + +/* #include #include @@ -127,5 +140,6 @@ namespace boost } // namespace boost #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +*/ #endif diff --git a/include/boost/range/size_type.hpp b/include/boost/range/size_type.hpp index 3143dff..9388bd4 100755 --- a/include/boost/range/size_type.hpp +++ b/include/boost/range/size_type.hpp @@ -16,7 +16,54 @@ #endif #include +#include +namespace boost +{ + namespace range_detail + { + template< class T > + struct add_unsigned; + + template<> + struct add_unsigned + { + typedef unsigned short type; + }; + + template<> + struct add_unsigned + { + typedef unsigned int type; + }; + + template<> + struct add_unsigned + { + typedef unsigned long type; + }; + +#ifdef BOOST_HAS_LONG_LONG + + template<> + struct add_unsigned + { + typedef unsigned long long type; + }; +#endif + + } + + template< class T > + struct range_size + { + typedef BOOST_DEDUCED_TYPENAME range_detail::add_unsigned< + BOOST_DEDUCED_TYPENAME range_difference::type >::type + type; + }; +} + +/* #ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #include #else @@ -123,5 +170,6 @@ namespace boost } // namespace boost #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +*/ #endif diff --git a/include/boost/range/value_type.hpp b/include/boost/range/value_type.hpp index 7275173..7644ff5 100755 --- a/include/boost/range/value_type.hpp +++ b/include/boost/range/value_type.hpp @@ -16,12 +16,26 @@ #endif #include +#include -#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION -#include -#else +//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +//#include +//#else #include + +namespace boost +{ + template< class T > + struct range_value + { + typedef BOOST_DEDUCED_TYPENAME iterator_value< + BOOST_DEDUCED_TYPENAME range_const_iterator::type >::type + type; + }; +} + +/* #include #include @@ -126,7 +140,7 @@ namespace boost }; } // namespace boost - -#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +*/ +//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION #endif