Clean up after John Maddocks's (finally effective!) Borland fixes

[SVN r9111]
This commit is contained in:
Dave Abrahams
2001-02-11 14:07:11 +00:00
parent b2701f9f78
commit 170b44763d

View File

@ -28,6 +28,8 @@
// Incrementable. // Incrementable.
// //
// Revision History // Revision History
// 11 Feb 2001 Clean up after John Maddocks's (finally effective!) Borland
// fixes (David Abrahams).
// 10 Feb 2001 Use new iterator_adaptor<> interface (David Abrahams) // 10 Feb 2001 Use new iterator_adaptor<> interface (David Abrahams)
// 10 Feb 2001 Rolled in supposed Borland fixes from John Maddock, but not // 10 Feb 2001 Rolled in supposed Borland fixes from John Maddock, but not
// seeing any improvement yet (David Abrahams) // seeing any improvement yet (David Abrahams)
@ -63,14 +65,11 @@ namespace detail {
// iterator_category and difference_type for a counting_iterator at // iterator_category and difference_type for a counting_iterator at
// compile-time based on whether or not it wraps an integer or an iterator, // compile-time based on whether or not it wraps an integer or an iterator,
// using "poor man's partial specialization". // using "poor man's partial specialization".
template <bool is_integer> struct counting_iterator_traits_select template <bool is_integer> struct counting_iterator_traits_select;
#ifndef __BORLANDC__
;
// Incrementable is an iterator type // Incrementable is an iterator type
template <> template <>
struct counting_iterator_traits_select<false> struct counting_iterator_traits_select<false>
#endif
{ {
template <class Incrementable> template <class Incrementable>
struct traits struct traits
@ -102,13 +101,11 @@ namespace detail {
// the iterator wraps an integer or an iterator, using "poor man's partial // the iterator wraps an integer or an iterator, using "poor man's partial
// specialization". // specialization".
template <bool is_integer> struct distance_policy_select template <bool is_integer> struct distance_policy_select;
#ifndef __BORLANDC__
;
// A policy for wrapped iterators // A policy for wrapped iterators
template <> template <>
struct distance_policy_select<false> struct distance_policy_select<false>
#endif
{ {
template <class Distance, class Incrementable> template <class Distance, class Incrementable>
struct policy { struct policy {
@ -130,36 +127,31 @@ namespace detail {
// Try to detect numeric types at compile time in ways compatible with the // Try to detect numeric types at compile time in ways compatible with the
// limitations of the compiler and library. // limitations of the compiler and library.
#ifndef __BORLANDC__
template <class T> template <class T>
struct is_numeric { struct is_numeric {
// For a while, this wasn't true, but we rely on it below. This is a regression assert. // For a while, this wasn't true, but we rely on it below. This is a regression assert.
BOOST_STATIC_ASSERT(::boost::is_integral<char>::value); BOOST_STATIC_ASSERT(::boost::is_integral<char>::value);
#if !defined(__BORLANDC__)
enum { value = enum { value =
#ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS # ifndef BOOST_NO_LIMITS_COMPILE_TIME_CONSTANTS
std::numeric_limits<T>::is_specialized std::numeric_limits<T>::is_specialized
#else # else
boost::is_convertible<int,T>::value && boost::is_convertible<T,int>::value boost::is_convertible<int,T>::value && boost::is_convertible<T,int>::value
#endif # endif
}; };
};
#else #else
// Borland seems to have a strange problem with is_numeric, just delegate // Borland seems to have a strange problem with using an enum in this case
// to is_arithmetic instead:
template <class T>
struct is_numeric {
// For a while, this wasn't true, but we rely on it below. This is a regression assert.
BOOST_STATIC_ASSERT(::boost::is_integral<char>::value);
static const bool value = ::boost::is_arithmetic<T>::value; static const bool value = ::boost::is_arithmetic<T>::value;
};
#endif #endif
};
// Compute the distance over arbitrary numeric and/or iterator types // Compute the distance over arbitrary numeric and/or iterator types
template <class Distance, class Incrementable> template <class Distance, class Incrementable>
Distance any_distance(Incrementable start, Incrementable finish, Distance* = 0) Distance any_distance(Incrementable start, Incrementable finish, Distance* = 0)
{ {
return distance_policy_select<( return distance_policy_select<(
::boost::detail::is_numeric<Incrementable>::value)>::template is_numeric<Incrementable>::value)>::template
policy<Distance, Incrementable>::distance(start, finish); policy<Distance, Incrementable>::distance(start, finish);
} }
@ -168,11 +160,9 @@ namespace detail {
template <class Incrementable> template <class Incrementable>
struct counting_iterator_traits { struct counting_iterator_traits {
private: private:
BOOST_STATIC_ASSERT(::boost::detail::is_numeric<Incrementable>::value == ::boost::is_arithmetic<Incrementable>::value);
typedef ::boost::detail::counting_iterator_traits_select<( typedef ::boost::detail::counting_iterator_traits_select<(
::boost::detail::is_numeric<Incrementable>::value detail::is_numeric<Incrementable>::value
)> binder; )>::template traits<Incrementable> traits;
typedef typename binder::template traits<Incrementable> traits;
public: public:
typedef Incrementable value_type; typedef Incrementable value_type;
typedef const Incrementable& reference; typedef const Incrementable& reference;