diff options
author | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-04-25 23:04:16 +0000 |
---|---|---|
committer | paolo <paolo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-04-25 23:04:16 +0000 |
commit | 861960977ab98474999e942ab31436fbc028a3ea (patch) | |
tree | 48945cd71bd2a84817000d24b34676f06c3e713a /libstdc++-v3 | |
parent | 8de5c43ea89970802e1e0aade14cb03909d15de1 (diff) | |
download | gcc-861960977ab98474999e942ab31436fbc028a3ea.tar.gz |
2011-04-25 Paolo Carlini <paolo.carlini@oracle.com>
* include/std/type_traits (struct underlying_type): Add.
* testsuite/20_util/underlying_type/requirements/typedefs-1.cc: New.
* testsuite/20_util/underlying_type/requirements/typedefs-2.cc:
Likewise.
* testsuite/20_util/underlying_type/requirements/
explicit_instantiation.cc: Likewise.
* testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error
line number.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@172944 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3')
6 files changed, 144 insertions, 2 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 9d767f5beef..9f39823f149 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,14 @@ +2011-04-25 Paolo Carlini <paolo.carlini@oracle.com> + + * include/std/type_traits (struct underlying_type): Add. + * testsuite/20_util/underlying_type/requirements/typedefs-1.cc: New. + * testsuite/20_util/underlying_type/requirements/typedefs-2.cc: + Likewise. + * testsuite/20_util/underlying_type/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error + line number. + 2011-04-24 Paolo Carlini <paolo.carlini@oracle.com> * include/parallel/multiway_merge.h: Uglify equally_split diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 11f1b012261..6d33416c330 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1581,7 +1581,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type; }; - /// underlying_type (still unimplemented) + /// underlying_type + template<typename _Tp> + struct underlying_type + { + typedef __underlying_type(_Tp) type; + }; /// declval template<typename _Tp> diff --git a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc index debff581af5..af1522b7a40 100644 --- a/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc +++ b/libstdc++-v3/testsuite/20_util/declval/requirements/1_neg.cc @@ -19,7 +19,7 @@ // with this library; see the file COPYING3. If not see // <http://www.gnu.org/licenses/>. -// { dg-error "static assertion failed" "" { target *-*-* } 1598 } +// { dg-error "static assertion failed" "" { target *-*-* } 1603 } #include <utility> diff --git a/libstdc++-v3/testsuite/20_util/underlying_type/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/underlying_type/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..159e9bd352c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/underlying_type/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// 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/>. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +namespace std +{ + typedef enum E1 : unsigned { } test_type1; + typedef enum E2 : char { } test_type2; + typedef enum class E3 { } test_type3; + typedef enum class E4 : unsigned char { c = 1 } test_type4; + typedef enum class E5 : int { a = -1, b = 1 } test_type5; + typedef enum class E6 : long { c = __LONG_MAX__ } test_type6; + + template struct underlying_type<test_type1>; + template struct underlying_type<test_type2>; + template struct underlying_type<test_type3>; + template struct underlying_type<test_type4>; + template struct underlying_type<test_type5>; + template struct underlying_type<test_type6>; +} diff --git a/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-1.cc b/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-1.cc new file mode 100644 index 00000000000..777a646845e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-1.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +void test01() +{ + typedef enum E1 : unsigned { } test_type1; + typedef enum E2 : char { } test_type2; + typedef enum class E3 { } test_type3; + typedef enum class E4 : unsigned char { c = 1 } test_type4; + typedef enum class E5 : int { a = -1, b = 1 } test_type5; + typedef enum class E6 : long { c = __LONG_MAX__ } test_type6; + + // Check for required typedef + typedef std::underlying_type<test_type1>::type type1; + typedef std::underlying_type<test_type2>::type type2; + typedef std::underlying_type<test_type3>::type type3; + typedef std::underlying_type<test_type4>::type type4; + typedef std::underlying_type<test_type5>::type type5; + typedef std::underlying_type<test_type6>::type type6; +} diff --git a/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-2.cc new file mode 100644 index 00000000000..b204a4f20a5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-2.cc @@ -0,0 +1,44 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// 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/>. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include <type_traits> + +void test01() +{ + using namespace std; + + enum E1 : unsigned { }; + enum E2 : char { }; + enum class E3 { }; + enum class E4 : unsigned char { c = 1 }; + enum class E5 : int { a = -1, b = 1 }; + enum class E6 : long { c = __LONG_MAX__ }; + + static_assert(is_same<underlying_type<E1>::type, unsigned>::value, "Error"); + static_assert(is_same<underlying_type<E2>::type, char>::value, "Error"); + static_assert(is_same<underlying_type<E3>::type, int>::value, "Error"); + static_assert(is_same<underlying_type<E4>::type, + unsigned char>::value, "Error"); + static_assert(is_same<underlying_type<E5>::type, int>::value, "Error"); + static_assert(is_same<underlying_type<E6>::type, long>::value, "Error"); +} |