simplified metafunctions interface

[SVN r30889]
This commit is contained in:
Thorsten Jørgen Ottosen
2005-09-09 16:11:29 +00:00
parent 19d2d83d29
commit a47b8664f7
3 changed files with 86 additions and 10 deletions

View File

@ -16,12 +16,25 @@
#endif
#include <boost/range/config.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/difference_type.hpp>
#else
#include <boost/range/const_iterator.hpp>
#include <boost/iterator/iterator_traits.hpp>
namespace boost
{
template< class T >
struct range_difference
{
typedef BOOST_DEDUCED_TYPENAME iterator_difference<
BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type >::type
type;
};
}
//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//#include <boost/range/detail/difference_type.hpp>
//#else
/*
#include <cstddef>
#include <utility>
@ -127,5 +140,6 @@ namespace boost
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
*/
#endif

View File

@ -16,7 +16,54 @@
#endif
#include <boost/range/config.hpp>
#include <boost/range/difference_type.hpp>
namespace boost
{
namespace range_detail
{
template< class T >
struct add_unsigned;
template<>
struct add_unsigned<short>
{
typedef unsigned short type;
};
template<>
struct add_unsigned<int>
{
typedef unsigned int type;
};
template<>
struct add_unsigned<long>
{
typedef unsigned long type;
};
#ifdef BOOST_HAS_LONG_LONG
template<>
struct add_unsigned<long long>
{
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<T>::type >::type
type;
};
}
/*
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/size_type.hpp>
#else
@ -123,5 +170,6 @@ namespace boost
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
*/
#endif

View File

@ -16,12 +16,26 @@
#endif
#include <boost/range/config.hpp>
#include <boost/range/const_iterator.hpp>
#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#include <boost/range/detail/value_type.hpp>
#else
//#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
//#include <boost/range/detail/value_type.hpp>
//#else
#include <boost/iterator/iterator_traits.hpp>
namespace boost
{
template< class T >
struct range_value
{
typedef BOOST_DEDUCED_TYPENAME iterator_value<
BOOST_DEDUCED_TYPENAME range_const_iterator<T>::type >::type
type;
};
}
/*
#include <cstddef>
#include <utility>
@ -126,7 +140,7 @@ namespace boost
};
} // namespace boost
#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
*/
//#endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
#endif