aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorPaolo Carlini <paolo.carlini@oracle.com>2010-02-17 12:18:54 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2010-02-17 12:18:54 +0000
commitce4674f2a6ac6bb7b8926076adf92694443f3f1b (patch)
tree8f4cd303cff6ada2cf97e2e396a50200893298d3 /libstdc++-v3
parent96e41f16111dff01330090bdf037242a22b430a9 (diff)
downloadgcc-ce4674f2a6ac6bb7b8926076adf92694443f3f1b.zip
gcc-ce4674f2a6ac6bb7b8926076adf92694443f3f1b.tar.gz
gcc-ce4674f2a6ac6bb7b8926076adf92694443f3f1b.tar.bz2
limits: Implement resolution of DR 559 (CD1) in C++0x mode.
2010-02-17 Paolo Carlini <paolo.carlini@oracle.com> * include/std/limits: Implement resolution of DR 559 (CD1) in C++0x mode. * testsuite/18_support/numeric_limits/dr559.cc: New. From-SVN: r156830
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/ChangeLog6
-rw-r--r--libstdc++-v3/include/std/limits24
-rw-r--r--libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc100
3 files changed, 125 insertions, 5 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 99e78f5..5eff61a 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,9 @@
+2010-02-17 Paolo Carlini <paolo.carlini@oracle.com>
+
+ * include/std/limits: Implement resolution of DR 559 (CD1) in
+ C++0x mode.
+ * testsuite/18_support/numeric_limits/dr559.cc: New.
+
2010-02-16 Benjamin Kosnik <bkoz@redhat.com>
* src/ios_locale.cc: Fixes for -pedantic.
diff --git a/libstdc++-v3/include/std/limits b/libstdc++-v3/include/std/limits
index 76a5322..a633d78 100644
--- a/libstdc++-v3/include/std/limits
+++ b/libstdc++-v3/include/std/limits
@@ -45,10 +45,10 @@
//
// The numeric_limits<> traits document implementation-defined aspects
// of fundamental arithmetic data types (integers and floating points).
-// From Standard C++ point of view, there are 13 such types:
+// From Standard C++ point of view, there are 14 such types:
// * integers
// bool (1)
-// char, signed char, unsigned char (3)
+// char, signed char, unsigned char, wchar_t (4)
// short, unsigned short (2)
// int, unsigned (2)
// long, unsigned long (2)
@@ -62,7 +62,7 @@
// * integer
// long long, unsigned long long (2)
//
-// which brings us to 15 fundamental arithmetic data types in GNU C++.
+// which brings us to 16 fundamental arithmetic data types in GNU C++.
//
//
// Since a numeric_limits<> is a bit tricky to get right, we rely on
@@ -302,8 +302,22 @@ _GLIBCXX_BEGIN_NAMESPACE(std)
static _Tp denorm_min() throw() { return static_cast<_Tp>(0); }
};
- // Now there follow 15 explicit specializations. Yes, 15. Make sure
- // you get the count right.
+#ifdef __GXX_EXPERIMENTAL_CXX0X__
+ template<typename _Tp>
+ struct numeric_limits<const _Tp>
+ : public numeric_limits<_Tp> { };
+
+ template<typename _Tp>
+ struct numeric_limits<volatile _Tp>
+ : public numeric_limits<_Tp> { };
+
+ template<typename _Tp>
+ struct numeric_limits<const volatile _Tp>
+ : public numeric_limits<_Tp> { };
+#endif
+
+ // Now there follow 16 explicit specializations. Yes, 16. Make sure
+ // you get the count right. (18 in c++0x mode)
/// numeric_limits<bool> specialization.
template<>
diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc b/libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc
new file mode 100644
index 0000000..f541faa
--- /dev/null
+++ b/libstdc++-v3/testsuite/18_support/numeric_limits/dr559.cc
@@ -0,0 +1,100 @@
+// { dg-options "-std=gnu++0x" }
+
+// 2010-02-17 Paolo Carlini <paolo.carlini@oracle.com>
+//
+// Copyright (C) 2010 Free Software Foundation
+//
+// 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
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3. If not see
+// <http://www.gnu.org/licenses/>.
+
+#include <limits>
+#include <type_traits>
+#include <testsuite_hooks.h>
+
+template<typename T>
+ void do_test_aux()
+ {
+ bool test __attribute__((unused)) = true;
+ typedef std::numeric_limits<T> cv_limits;
+ typedef std::numeric_limits<typename std::remove_cv<T>::type> limits;
+
+ VERIFY( cv_limits::is_specialized == limits::is_specialized );
+ VERIFY( cv_limits::min() == limits::min() );
+ VERIFY( cv_limits::max() == limits::max() );
+ VERIFY( cv_limits::digits == limits::digits );
+ VERIFY( cv_limits::digits10 == limits::digits10 );
+ VERIFY( cv_limits::is_signed == limits::is_signed );
+ VERIFY( cv_limits::is_integer == limits::is_integer );
+ VERIFY( cv_limits::is_exact == limits::is_exact );
+ VERIFY( cv_limits::radix == limits::radix );
+ VERIFY( cv_limits::epsilon() == limits::epsilon() );
+ VERIFY( cv_limits::round_error() == limits::round_error() );
+ VERIFY( cv_limits::min_exponent == limits::min_exponent );
+ VERIFY( cv_limits::min_exponent10 == limits::min_exponent10 );
+ VERIFY( cv_limits::max_exponent == limits::max_exponent );
+ VERIFY( cv_limits::max_exponent10 == limits::max_exponent10 );
+ VERIFY( cv_limits::has_infinity == limits::has_infinity );
+ VERIFY( cv_limits::has_quiet_NaN == limits::has_quiet_NaN );
+ VERIFY( cv_limits::has_signaling_NaN == limits::has_signaling_NaN );
+ VERIFY( cv_limits::has_denorm == limits::has_denorm );
+ VERIFY( cv_limits::has_denorm_loss == limits::has_denorm_loss );
+ VERIFY( cv_limits::infinity() == limits::infinity() );
+ if (!std::is_floating_point<T>::value)
+ {
+ VERIFY( cv_limits::quiet_NaN() == limits::quiet_NaN() );
+ VERIFY( cv_limits::signaling_NaN() == limits::signaling_NaN() );
+ }
+ VERIFY( cv_limits::denorm_min() == limits::denorm_min() );
+ VERIFY( cv_limits::is_iec559 == limits::is_iec559 );
+ VERIFY( cv_limits::is_bounded == limits::is_bounded );
+ VERIFY( cv_limits::is_modulo == limits::is_modulo );
+ VERIFY( cv_limits::traps == limits::traps );
+ VERIFY( cv_limits::tinyness_before == limits::tinyness_before );
+ VERIFY( cv_limits::round_style == limits::round_style );
+ }
+
+template<typename T>
+ void
+ do_test()
+ {
+ do_test_aux<T>();
+ do_test_aux<const T>();
+ do_test_aux<volatile T>();
+ do_test_aux<const volatile T>();
+ }
+
+// DR 559.
+int main()
+{
+ do_test<bool>();
+ do_test<char>();
+ do_test<signed char>();
+ do_test<unsigned char>();
+ do_test<wchar_t>();
+ do_test<char16_t>();
+ do_test<char32_t>();
+ do_test<short>();
+ do_test<unsigned short>();
+ do_test<int>();
+ do_test<unsigned int>();
+ do_test<long>();
+ do_test<unsigned long>();
+ do_test<long long>();
+ do_test<unsigned long long>();
+ do_test<float>();
+ do_test<double>();
+ do_test<long double>();
+ return 0;
+}