From: Jonathan Wakely Date: Tue, 5 Nov 2013 22:57:36 +0000 (+0000) Subject: N3655 C++1y TransformationTraits Redux X-Git-Tag: releases/gcc-4.9.0~3013 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4457e88ce188401b0a19b5064d182584c61cbeda;p=thirdparty%2Fgcc.git N3655 C++1y TransformationTraits Redux N3655 C++1y TransformationTraits Redux * include/std/type_traits (remove_const_t, remove_volatile_t, remove_cv_t, add_const_t, add_volatile_t, add_cv_t, remove_reference_t, add_lvalue_reference_t, add_rvalue_reference_t, make_signed_t, make_unsigned_t, remove_extent_t, remove_all_extents_t, remove_pointer_t, add_pointer_t, aligned_storage_t, decay_t, enable_if_t, conditional_t, common_type_t, underlying_type_t, result_of_t): Define. * doc/xml/manual/status_cxx2014.xml: Update. * testsuite/20_util/add_lvalue_reference/requirements/typedefs-3.cc: New. * testsuite/20_util/add_rvalue_reference/requirements/typedefs-3.cc: New. * testsuite/20_util/common_type/requirements/typedefs-3.cc: New. * testsuite/20_util/conditional/requirements/typedefs-2.cc: New. * testsuite/20_util/decay/requirements/typedefs-2.cc: New. * testsuite/20_util/enable_if/requirements/typedefs-2.cc: New. * testsuite/20_util/make_signed/requirements/typedefs-3.cc: New. * testsuite/20_util/make_unsigned/requirements/typedefs-3.cc: New. * testsuite/20_util/remove_reference/requirements/typedefs.cc: New. * testsuite/20_util/result_of/requirements/typedefs.cc: New. * testsuite/20_util/underlying_type/requirements/typedefs-3.cc: New. * testsuite/20_util/common_type/requirements/typedefs-2.cc: Change to compile-only test. * testsuite/20_util/decay/requirements/typedefs.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs-1.cc: Likewise. * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error line number. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. From-SVN: r204426 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index da9e5e3a8ef1..4253a8025333 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,38 @@ +2013-11-05 Jonathan Wakely + + N3655 C++1y TransformationTraits Redux + * include/std/type_traits (remove_const_t, remove_volatile_t, + remove_cv_t, add_const_t, add_volatile_t, add_cv_t, remove_reference_t, + add_lvalue_reference_t, add_rvalue_reference_t, make_signed_t, + make_unsigned_t, remove_extent_t, remove_all_extents_t, + remove_pointer_t, add_pointer_t, aligned_storage_t, decay_t, + enable_if_t, conditional_t, common_type_t, underlying_type_t, + result_of_t): Define. + * doc/xml/manual/status_cxx2014.xml: Update. + * testsuite/20_util/add_lvalue_reference/requirements/typedefs-3.cc: + New. + * testsuite/20_util/add_rvalue_reference/requirements/typedefs-3.cc: + New. + * testsuite/20_util/common_type/requirements/typedefs-3.cc: New. + * testsuite/20_util/conditional/requirements/typedefs-2.cc: New. + * testsuite/20_util/decay/requirements/typedefs-2.cc: New. + * testsuite/20_util/enable_if/requirements/typedefs-2.cc: New. + * testsuite/20_util/make_signed/requirements/typedefs-3.cc: New. + * testsuite/20_util/make_unsigned/requirements/typedefs-3.cc: New. + * testsuite/20_util/remove_reference/requirements/typedefs.cc: New. + * testsuite/20_util/result_of/requirements/typedefs.cc: New. + * testsuite/20_util/underlying_type/requirements/typedefs-3.cc: New. + * testsuite/20_util/common_type/requirements/typedefs-2.cc: Change to + compile-only test. + * testsuite/20_util/decay/requirements/typedefs.cc: Likewise. + * testsuite/20_util/make_signed/requirements/typedefs-1.cc: Likewise. + * testsuite/20_util/declval/requirements/1_neg.cc: Adjust dg-error + line number. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: + Likewise. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Likewise. + 2013-11-05 Jonathan Wakely * doc/xml/manual/status_cxx2011.xml: Document aligned_union as diff --git a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml index b368a810e6a7..0e0ac37a9e85 100644 --- a/libstdc++-v3/doc/xml/manual/status_cxx2014.xml +++ b/libstdc++-v3/doc/xml/manual/status_cxx2014.xml @@ -178,7 +178,6 @@ particular release. - N3658 @@ -202,7 +201,6 @@ particular release. - N3421 @@ -227,26 +225,24 @@ particular release. - - + N3672 A proposal to add a utility class to represent optional objects - N - + Y + Moved from C++14 to Library Fundamentals TS - N3655 TransformationTraits Redux - N + Y @@ -259,7 +255,7 @@ particular release. C++ Dynamic Arrays N - + Moved from C++14 to Library Fundamentals TS diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index eef9df6998c1..3239564c64ed 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1438,6 +1438,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION add_const::type>::type type; }; +#if __cplusplus > 201103L + /// Alias template for remove_const + template + using remove_const_t = typename remove_const<_Tp>::type; + + /// Alias template for remove_volatile + template + using remove_volatile_t = typename remove_volatile<_Tp>::type; + + /// Alias template for remove_cv + template + using remove_cv_t = typename remove_cv<_Tp>::type; + + /// Alias template for add_const + template + using add_const_t = typename add_const<_Tp>::type; + + /// Alias template for add_volatile + template + using add_volatile_t = typename add_volatile<_Tp>::type; + + /// Alias template for add_cv + template + using add_cv_t = typename add_cv<_Tp>::type; +#endif // Reference transformations. @@ -1482,6 +1507,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __add_rvalue_reference_helper<_Tp> { }; +#if __cplusplus > 201103L + /// Alias template for remove_reference + template + using remove_reference_t = typename remove_reference<_Tp>::type; + + /// Alias template for add_lvalue_reference + template + using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; + + /// Alias template for add_rvalue_reference + template + using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; +#endif // Sign modifications. @@ -1679,6 +1717,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct make_signed; +#if __cplusplus > 201103L + /// Alias template for make_signed + template + using make_signed_t = typename make_signed<_Tp>::type; + + /// Alias template for make_unsigned + template + using make_unsigned_t = typename make_unsigned<_Tp>::type; +#endif // Array modifications. @@ -1708,6 +1755,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct remove_all_extents<_Tp[]> { typedef typename remove_all_extents<_Tp>::type type; }; +#if __cplusplus > 201103L + /// Alias template for remove_extent + template + using remove_extent_t = typename remove_extent<_Tp>::type; + + /// Alias template for remove_all_extents + template + using remove_all_extents_t = typename remove_all_extents<_Tp>::type; +#endif // Pointer modifications. @@ -1740,6 +1796,15 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __add_pointer_helper<_Tp> { }; +#if __cplusplus > 201103L + /// Alias template for remove_pointer + template + using remove_pointer_t = typename remove_pointer<_Tp>::type; + + /// Alias template for add_pointer + template + using add_pointer_t = typename add_pointer<_Tp>::type; +#endif template struct __aligned_storage_msa @@ -2102,6 +2167,37 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >::type { }; +#if __cplusplus > 201103L + /// Alias template for aligned_storage + template::__type)> + using aligned_storage_t = typename aligned_storage<_Len, _Align>::type; + + /// Alias template for decay + template + using decay_t = typename decay<_Tp>::type; + + /// Alias template for enable_if + template + using enable_if_t = typename enable_if<_Cond, _Tp>::type; + + /// Alias template for conditional + template + using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type; + + /// Alias template for common_type + template + using common_type_t = typename common_type<_Tp...>::type; + + /// Alias template for underlying_type + template + using underlying_type_t = typename underlying_type<_Tp>::type; + + /// Alias template for result_of + template + using result_of_t = typename result_of<_Tp>::type; +#endif + /// @} group metaprogramming /** diff --git a/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000000..24e73cc23f32 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/add_lvalue_reference/requirements/typedefs.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013 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 +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +using namespace std; + +static_assert( is_same::type, + add_lvalue_reference_t>(), + "add_lvalue_reference_t" ); diff --git a/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/typedefs.cc new file mode 100644 index 000000000000..18a6964c8e3f --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/add_rvalue_reference/requirements/typedefs.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013 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 +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +using namespace std; + +static_assert( is_same::type, + add_rvalue_reference_t>(), + "add_rvalue_reference_t" ); diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc index 07a694ba4de7..f662d32d5db5 100644 --- a/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-2.cc @@ -1,4 +1,5 @@ -// { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } // 2009-11-12 Paolo Carlini // // Copyright (C) 2009-2013 Free Software Foundation, Inc. @@ -19,53 +20,53 @@ // . #include -#include // DR 1255. void test01() { - bool test __attribute__((unused)) = true; using std::common_type; using std::is_same; - VERIFY( (is_same::type, void>::value) ); - VERIFY( (is_same::type, void>::value) ); - VERIFY( (is_same::type, void>::value) ); - VERIFY( (is_same::type, void>::value) ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); - VERIFY( (is_same::type, void>::value) ); - VERIFY( (is_same::type, void>::value) ); - VERIFY( (is_same::type, void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - VERIFY( (is_same::type, - void>::value) ); - } - -int main() -{ - test01(); - return 0; + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, + void>(), "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, + void>(), "common_type" ); + static_assert( is_same::type, + void>(), "common_type" ); + static_assert( is_same::type, + void>(), "common_type" ); + static_assert( is_same::type, void>(), + "common_type" ); + static_assert( is_same::type, + void>(), "common_type" ); + static_assert( is_same::type, + void>(), "common_type" ); + static_assert( is_same::type, + void>(), + "common_type" ); } diff --git a/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-3.cc b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-3.cc new file mode 100644 index 000000000000..52852fcca76a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/common_type/requirements/typedefs-3.cc @@ -0,0 +1,27 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } +// +// Copyright (C) 2013 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 +// . + +#include + +using namespace std; + +static_assert( is_same::type, + common_type_t>(), + "common_type_t" ); diff --git a/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs-2.cc new file mode 100644 index 000000000000..94edeea7fb3e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs-2.cc @@ -0,0 +1,33 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013 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 +// . + + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +using namespace std; + +static_assert( is_same::type, + conditional_t>(), + "conditional_t" ); +static_assert( is_same::type, + conditional_t>(), + "conditional_t" ); diff --git a/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs-2.cc new file mode 100644 index 000000000000..774e22e2ff12 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs-2.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013 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 +// . + +#include + +using namespace std; + +template + using test = is_same; + +static_assert( test, decay_t>(), "decay" ); +static_assert( test, decay_t>(), + "decay" ); +static_assert( test, decay_t>(), "decay" ); +typedef void (fn_type) (); +static_assert( test, decay_t>(), "decay" ); +typedef void (cfn_type) () const; +static_assert( test, decay_t>(), "decay" ); diff --git a/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc index 51b2c5fa0c4e..11589e473f01 100644 --- a/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc +++ b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc @@ -1,4 +1,5 @@ -// { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } // 2007-05-03 Benjamin Kosnik // @@ -19,38 +20,31 @@ // with this library; see the file COPYING3. If not see // . -#include #include -#include void test01() { - bool test __attribute__((unused)) = true; using std::decay; using std::is_same; // Positive tests. typedef decay::type test1_type; - VERIFY( (is_same::value) ); + static_assert( is_same(), "decay" ); // NB: DR 705. typedef decay::type test2_type; - VERIFY( (is_same::value) ); + static_assert( is_same(), "decay" ); typedef decay::type test3_type; - VERIFY( (is_same::type*>::value) ); + static_assert( is_same::type*>(), + "decay" ); typedef void (fn_type) (); typedef decay::type test4_type; - VERIFY( (is_same::type>::value) ); + static_assert( is_same::type>(), + "decay" ); typedef void (cfn_type) () const; typedef decay::type test5_type; - VERIFY( (is_same::value) ); -} - -int main() -{ - test01(); - return 0; + static_assert( is_same(), "decay" ); } 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 1aeba824ec5e..d01bdf31fa25 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 // . -// { dg-error "static assertion failed" "" { target *-*-* } 1938 } +// { dg-error "static assertion failed" "" { target *-*-* } 2003 } #include diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs-2.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs-2.cc new file mode 100644 index 000000000000..42b7f4fe0190 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs-2.cc @@ -0,0 +1,29 @@ +// { dg-do compile } +// { dg-options "-std=gnu++1y" } + +// Copyright (C) 2013 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 +// . + +#include + +using namespace std; + +static_assert( is_same::type, enable_if_t>(), + "enable_if_t" ); +struct X; +static_assert( is_same::type, enable_if_t>(), + "enable_if_t" ); diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc index a0e70e6db631..18791c6a9c9d 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-1.cc @@ -1,4 +1,5 @@ -// { dg-options "-std=gnu++0x" } +// { dg-options "-std=gnu++11" } +// { dg-do compile } // 2007-05-03 Benjamin Kosnik // @@ -20,55 +21,57 @@ // . #include -#include enum test_enum { first_selection }; void test01() { - bool test __attribute__((unused)) = true; using std::make_signed; using std::is_same; using std::is_signed; // Positive tests. typedef make_signed::type test2_type; - VERIFY( (is_same::value) ); + static_assert( is_same::value, + "make_signed" ); typedef make_signed::type test21c_type; - VERIFY( (is_same::value) ); + static_assert( is_same::value, + "make_signed" ); typedef make_signed::type test21v_type; - VERIFY( (is_same::value) ); + static_assert( is_same::value, + "make_signed" ); typedef make_signed::type test21cv_type; - VERIFY( (is_same::value) ); + static_assert( is_same::value, + "make_signed" ); typedef make_signed::type test22_type; - VERIFY( (is_same::value) ); + static_assert( is_same::value, + "make_signed" ); #ifdef _GLIBCXX_USE_WCHAR_T typedef make_signed::type test23_type; - VERIFY( (is_same::value) ); + static_assert( is_same::value, + "make_signed" ); #endif // Chapter 48, chapter 20. Smallest rank such that new signed type same size. typedef make_signed::type test24_type; - VERIFY( is_signed::value ); - VERIFY( sizeof(test24_type) == sizeof(test_enum) ); + static_assert( is_signed::value, + "make_signed makes signed type" ); + static_assert( sizeof(test24_type) == sizeof(test_enum), + "make_signed makes type of same size" ); // GNU Extensions. #ifdef _GLIBCXX_USE_INT128 typedef make_signed::type test25_type; - VERIFY( (is_same::value) ); + static_assert( is_same::value, + "make_signed" ); typedef make_signed<__int128>::type test26_type; - VERIFY( (is_same::value) ); + static_assert( is_same::value, + "make_signed<__int128>" ); #endif } - -int main() -{ - test01(); - return 0; -} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-3.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-3.cc new file mode 100644 index 000000000000..f76900403885 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs-3.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013 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 +// . + +#include + +using namespace std; + +template + using test = is_same; + +static_assert( test, make_signed_t>(), + "make_signed_t" ); + +static_assert( test, make_signed_t>(), + "make_signed_t" ); + +static_assert( test, make_signed_t>(), + "make_signed_t" ); diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc index 53090b345642..30a19cf0c862 100644 --- a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1676 } -// { dg-error "declaration of" "" { target *-*-* } 1640 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1714 } +// { dg-error "declaration of" "" { target *-*-* } 1678 } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-3.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-3.cc new file mode 100644 index 000000000000..4bcabe5548d3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs-3.cc @@ -0,0 +1,35 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013 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 +// . + +#include + +using namespace std; + +template + using test = is_same; + +static_assert( test, make_unsigned_t>(), + "make_unsigned_t" ); + +static_assert( test, make_unsigned_t>(), + "make_unsigned_t" ); + +static_assert( test, make_unsigned_t>(), + "make_unsigned_t" ); diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc index 7b7e59911f45..567908e43d65 100644 --- a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -48,5 +48,5 @@ void test01() // { dg-error "required from here" "" { target *-*-* } 40 } // { dg-error "required from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1594 } -// { dg-error "declaration of" "" { target *-*-* } 1558 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1632 } +// { dg-error "declaration of" "" { target *-*-* } 1596 } diff --git a/libstdc++-v3/testsuite/20_util/remove_reference/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/remove_reference/requirements/typedefs.cc new file mode 100644 index 000000000000..209cca42c21b --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/remove_reference/requirements/typedefs.cc @@ -0,0 +1,30 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013 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 +// . + +#include + +using namespace std; + +static_assert( is_same::type, remove_reference_t>(), + "remove_reference_t" ); +static_assert( is_same::type, remove_reference_t>(), + "remove_reference_t" ); +static_assert( is_same::type, remove_reference_t>(), + "remove_reference_t" ); diff --git a/libstdc++-v3/testsuite/20_util/result_of/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/result_of/requirements/typedefs.cc new file mode 100644 index 000000000000..7c0070411607 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/result_of/requirements/typedefs.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } + +// Copyright (C) 2013 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 +// . + +#include + +using namespace std; + +using F1 = char(*)(char); +static_assert( is_same::type, result_of_t>(), + "result_of_t" ); + +struct X { }; +using F2 = int X::*; +static_assert( is_same::type, result_of_t>(), + "result_of_t" ); diff --git a/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-3.cc b/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-3.cc new file mode 100644 index 000000000000..a4c5257499da --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/underlying_type/requirements/typedefs-3.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++1y" } +// { dg-do compile } +// +// Copyright (C) 2013 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 +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +using namespace std; + +enum E : long { }; + +static_assert( is_same::type, + underlying_type_t>(), + "underlying_type_t" );