Borland compiler fixes

[SVN r9110]
This commit is contained in:
John Maddock
2001-02-11 12:50:06 +00:00
parent ad4c5ab089
commit b2701f9f78

View File

@ -130,28 +130,36 @@ 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);
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
#elif defined(__BORLANDC__)
::boost::is_arithmetic<T>::value
#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
// Borland seems to have a strange problem with is_numeric, just delegate
// 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;
};
#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<(
is_numeric<Incrementable>::value)>::template ::boost::detail::is_numeric<Incrementable>::value)>::template
policy<Distance, Incrementable>::distance(start, finish); policy<Distance, Incrementable>::distance(start, finish);
} }
@ -160,10 +168,11 @@ namespace detail {
template <class Incrementable> template <class Incrementable>
struct counting_iterator_traits { struct counting_iterator_traits {
private: private:
enum {numeric = detail::is_numeric<Incrementable>::value }; BOOST_STATIC_ASSERT(::boost::detail::is_numeric<Incrementable>::value == ::boost::is_arithmetic<Incrementable>::value);
typedef typename detail::counting_iterator_traits_select<( typedef ::boost::detail::counting_iterator_traits_select<(
numeric ::boost::detail::is_numeric<Incrementable>::value
)>::template traits<Incrementable> traits; )> binder;
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;