Commit 84979344 by Benjamin Kosnik Committed by Benjamin Kosnik

std_limits.h: Move static const data members out of generic template...


2002-03-08  Benjamin Kosnik  <bkoz@redhat.com>

	* include/std/std_limits.h: Move static const data members out of
	generic template, into base class __numeric_limits_base.
	* src/limits.cc: Add definitions.
	* config/linker-map.gnu: Add __numeric_limits_base.
	* testsuite/18_support/numeric_limits.cc: Declare test in scope.

From-SVN: r50447
parent 1e4e95d6
2002-03-08 Benjamin Kosnik <bkoz@redhat.com>
* include/std/std_limits.h: Move static const data members out of
generic template, into base class __numeric_limits_base.
* src/limits.cc: Add definitions.
* config/linker-map.gnu: Add __numeric_limits_base.
* testsuite/18_support/numeric_limits.cc: Declare test in scope.
2002-03-07 Benjamin Kosnik <bkoz@redhat.com> 2002-03-07 Benjamin Kosnik <bkoz@redhat.com>
* include/bits/stl_alloc.h: Add extern implicit allocator * include/bits/stl_alloc.h: Add extern implicit allocator
......
...@@ -33,7 +33,8 @@ GLIBCPP_3.1 { ...@@ -33,7 +33,8 @@ GLIBCPP_3.1 {
std::__throw_*; std::__throw_*;
std::__basic_file*; std::__basic_file*;
std::__num_base*; std::__num_base*;
std::__timepunct* std::__timepunct*;
std::__numeric_limits_base*
}; };
# Names not in an 'extern' block are mangled names. # Names not in an 'extern' block are mangled names.
......
...@@ -908,140 +908,52 @@ namespace std ...@@ -908,140 +908,52 @@ namespace std
// //
// The primary class traits // The primary class traits
// //
struct __numeric_limits_base
{
static const bool is_specialized = false;
static const int digits = 0;
static const int digits10 = 0;
static const bool is_signed = false;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 0;
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static const bool is_iec559 = false;
static const bool is_bounded = false;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
};
template<typename _Tp> template<typename _Tp>
struct numeric_limits struct numeric_limits : public __numeric_limits_base
{ {
static const bool is_specialized = false;
static _Tp min() throw() { return static_cast<_Tp>(0); } static _Tp min() throw() { return static_cast<_Tp>(0); }
static _Tp max() throw() { return static_cast<_Tp>(0); } static _Tp max() throw() { return static_cast<_Tp>(0); }
static const int digits = 0;
static const int digits10 = 0;
static const bool is_signed = false;
static const bool is_integer = false;
static const bool is_exact = false;
static const int radix = 0;
static _Tp epsilon() throw() { return static_cast<_Tp>(0); } static _Tp epsilon() throw() { return static_cast<_Tp>(0); }
static _Tp round_error() throw() { return static_cast<_Tp>(0); } static _Tp round_error() throw() { return static_cast<_Tp>(0); }
static const int min_exponent = 0;
static const int min_exponent10 = 0;
static const int max_exponent = 0;
static const int max_exponent10 = 0;
static const bool has_infinity = false;
static const bool has_quiet_NaN = false;
static const bool has_signaling_NaN = false;
static const float_denorm_style has_denorm = denorm_absent;
static const bool has_denorm_loss = false;
static _Tp infinity() throw() { return static_cast<_Tp>(0); } static _Tp infinity() throw() { return static_cast<_Tp>(0); }
static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); } static _Tp quiet_NaN() throw() { return static_cast<_Tp>(0); }
static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); } static _Tp signaling_NaN() throw() { return static_cast<_Tp>(0); }
static _Tp denorm_min() throw() { return static_cast<_Tp>(0); } static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
static const bool is_iec559 = false;
static const bool is_bounded = false;
static const bool is_modulo = false;
static const bool traps = false;
static const bool tinyness_before = false;
static const float_round_style round_style = round_toward_zero;
}; };
template<typename _Tp>
const bool
numeric_limits<_Tp>::is_specialized;
template<typename _Tp>
const int
numeric_limits<_Tp>::digits;
template<typename _Tp>
const int
numeric_limits<_Tp>::digits10;
template<typename _Tp>
const bool
numeric_limits<_Tp>::is_signed;
template<typename _Tp>
const bool
numeric_limits<_Tp>::is_integer;
template<typename _Tp>
const bool
numeric_limits<_Tp>::is_exact;
template<typename _Tp>
const int
numeric_limits<_Tp>::radix;
template<typename _Tp>
const int
numeric_limits<_Tp>::min_exponent;
template<typename _Tp>
const int
numeric_limits<_Tp>::min_exponent10;
template<typename _Tp>
const int
numeric_limits<_Tp>::max_exponent;
template<typename _Tp>
const int
numeric_limits<_Tp>::max_exponent10;
template<typename _Tp>
const bool
numeric_limits<_Tp>::has_infinity;
template<typename _Tp>
const bool
numeric_limits<_Tp>::has_quiet_NaN;
template<typename _Tp>
const bool
numeric_limits<_Tp>::has_signaling_NaN;
template<typename _Tp>
const float_denorm_style
numeric_limits<_Tp>::has_denorm;
template<typename _Tp>
const bool
numeric_limits<_Tp>::has_denorm_loss;
template<typename _Tp>
const bool
numeric_limits<_Tp>::is_iec559;
template<typename _Tp>
const bool
numeric_limits<_Tp>::is_bounded;
template<typename _Tp>
const bool
numeric_limits<_Tp>::is_modulo;
template<typename _Tp>
const bool
numeric_limits<_Tp>::traps;
template<typename _Tp>
const bool
numeric_limits<_Tp>::tinyness_before;
template<typename _Tp>
const float_round_style
numeric_limits<_Tp>::round_style;
// Now there follow 15 explicit specializations. Yes, 15. Make sure // Now there follow 15 explicit specializations. Yes, 15. Make sure
// you get the count right. // you get the count right.
template<> template<>
struct numeric_limits<bool> struct numeric_limits<bool>
{ {
......
// Static data members of -*- C++ -*- numeric_limits classes // Static data members of -*- C++ -*- numeric_limits classes
// Copyright (C) 1999, 2001 Free Software Foundation, Inc. // Copyright (C) 1999, 2001, 2002 Free Software Foundation, Inc.
// //
// This file is part of the GNU ISO C++ Library. This library is free // This file is part of the GNU ISO C++ Library. This library is free
// software; you can redistribute it and/or modify it under the // software; you can redistribute it and/or modify it under the
...@@ -38,6 +38,29 @@ ...@@ -38,6 +38,29 @@
namespace std namespace std
{ {
const bool __numeric_limits_base::is_specialized;
const int __numeric_limits_base::digits;
const int __numeric_limits_base::digits10;
const bool __numeric_limits_base::is_signed;
const bool __numeric_limits_base::is_integer;
const bool __numeric_limits_base::is_exact;
const int __numeric_limits_base::radix;
const int __numeric_limits_base::min_exponent;
const int __numeric_limits_base::min_exponent10;
const int __numeric_limits_base::max_exponent;
const int __numeric_limits_base::max_exponent10;
const bool __numeric_limits_base::has_infinity;
const bool __numeric_limits_base::has_quiet_NaN;
const bool __numeric_limits_base::has_signaling_NaN;
const float_denorm_style __numeric_limits_base::has_denorm;
const bool __numeric_limits_base::has_denorm_loss;
const bool __numeric_limits_base::is_iec559;
const bool __numeric_limits_base::is_bounded;
const bool __numeric_limits_base::is_modulo;
const bool __numeric_limits_base::traps;
const bool __numeric_limits_base::tinyness_before;
const float_round_style __numeric_limits_base::round_style;
// bool // bool
const bool numeric_limits<bool>::is_specialized; const bool numeric_limits<bool>::is_specialized;
const int numeric_limits<bool>::digits; const int numeric_limits<bool>::digits;
......
...@@ -55,6 +55,7 @@ DEFINE_EXTREMA(long double, LDBL_MIN, LDBL_MAX); ...@@ -55,6 +55,7 @@ DEFINE_EXTREMA(long double, LDBL_MIN, LDBL_MAX);
template<typename T> template<typename T>
void test_extrema() void test_extrema()
{ {
bool test = true;
VERIFY( extrema<T>::min == std::numeric_limits<T>::min() ); VERIFY( extrema<T>::min == std::numeric_limits<T>::min() );
VERIFY( extrema<T>::max == std::numeric_limits<T>::max() ); VERIFY( extrema<T>::max == std::numeric_limits<T>::max() );
} }
...@@ -73,6 +74,7 @@ template<> ...@@ -73,6 +74,7 @@ template<>
void test_extrema<long double>() void test_extrema<long double>()
{ {
typedef long double T; typedef long double T;
bool test = true;
VERIFY( (extrema<T>::min - std::numeric_limits<T>::min()) VERIFY( (extrema<T>::min - std::numeric_limits<T>::min())
< std::numeric_limits<T>::epsilon() ); < std::numeric_limits<T>::epsilon() );
VERIFY( (std::numeric_limits<T>::min() - extrema<T>::min) VERIFY( (std::numeric_limits<T>::min() - extrema<T>::min)
...@@ -92,6 +94,7 @@ void test_extrema<long double>() ...@@ -92,6 +94,7 @@ void test_extrema<long double>()
void test_sign() void test_sign()
{ {
bool test = true;
VERIFY( std::numeric_limits<char>::is_signed == char_is_signed ); VERIFY( std::numeric_limits<char>::is_signed == char_is_signed );
VERIFY( std::numeric_limits<signed char>::is_signed == true ); VERIFY( std::numeric_limits<signed char>::is_signed == true );
VERIFY( std::numeric_limits<unsigned char>::is_signed == false ); VERIFY( std::numeric_limits<unsigned char>::is_signed == false );
...@@ -230,9 +233,3 @@ int main() ...@@ -230,9 +233,3 @@ int main()
return 0; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment