Commit 4457e88c by Jonathan Wakely Committed by Jonathan Wakely

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
parent 592a16fc
2013-11-05 Jonathan Wakely <jwakely.gcc@gmail.com>
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 <jwakely.gcc@gmail.com>
* doc/xml/manual/status_cxx2011.xml: Document aligned_union as
missing.
......
......@@ -178,7 +178,6 @@ particular release.
<row>
<?dbhtml bgcolor="#C8C8B0" ?>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3658.html">
N3658
......@@ -202,7 +201,6 @@ particular release.
<row>
<?dbhtml bgcolor="#C8C8B0" ?>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2012/n3421.htm">
N3421
......@@ -227,26 +225,24 @@ particular release.
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3672.html">
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3793.html">
N3672
</link>
</entry>
<entry>A proposal to add a utility class to represent optional objects</entry>
<entry>N</entry>
<entry/>
<entry>Y</entry>
<entry>Moved from C++14 to Library Fundamentals TS</entry>
</row>
<row>
<?dbhtml bgcolor="#C8B0B0" ?>
<entry>
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://www.open-std.org/JTC1/sc22/WG21/docs/papers/2013/n3655.pdf">
N3655
</link>
</entry>
<entry>TransformationTraits Redux</entry>
<entry>N</entry>
<entry>Y</entry>
<entry/>
</row>
......@@ -259,7 +255,7 @@ particular release.
</entry>
<entry>C++ Dynamic Arrays</entry>
<entry>N</entry>
<entry/>
<entry>Moved from C++14 to Library Fundamentals TS</entry>
</row>
<row>
......
......@@ -1438,6 +1438,31 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
add_const<typename add_volatile<_Tp>::type>::type type;
};
#if __cplusplus > 201103L
/// Alias template for remove_const
template<typename _Tp>
using remove_const_t = typename remove_const<_Tp>::type;
/// Alias template for remove_volatile
template<typename _Tp>
using remove_volatile_t = typename remove_volatile<_Tp>::type;
/// Alias template for remove_cv
template<typename _Tp>
using remove_cv_t = typename remove_cv<_Tp>::type;
/// Alias template for add_const
template<typename _Tp>
using add_const_t = typename add_const<_Tp>::type;
/// Alias template for add_volatile
template<typename _Tp>
using add_volatile_t = typename add_volatile<_Tp>::type;
/// Alias template for add_cv
template<typename _Tp>
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<typename _Tp>
using remove_reference_t = typename remove_reference<_Tp>::type;
/// Alias template for add_lvalue_reference
template<typename _Tp>
using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type;
/// Alias template for add_rvalue_reference
template<typename _Tp>
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<bool>;
#if __cplusplus > 201103L
/// Alias template for make_signed
template<typename _Tp>
using make_signed_t = typename make_signed<_Tp>::type;
/// Alias template for make_unsigned
template<typename _Tp>
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<typename _Tp>
using remove_extent_t = typename remove_extent<_Tp>::type;
/// Alias template for remove_all_extents
template<typename _Tp>
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<typename _Tp>
using remove_pointer_t = typename remove_pointer<_Tp>::type;
/// Alias template for add_pointer
template<typename _Tp>
using add_pointer_t = typename add_pointer<_Tp>::type;
#endif
template<std::size_t _Len>
struct __aligned_storage_msa
......@@ -2102,6 +2167,37 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>::type
{ };
#if __cplusplus > 201103L
/// Alias template for aligned_storage
template<size_t _Len, size_t _Align =
__alignof__(typename __aligned_storage_msa<_Len>::__type)>
using aligned_storage_t = typename aligned_storage<_Len, _Align>::type;
/// Alias template for decay
template<typename _Tp>
using decay_t = typename decay<_Tp>::type;
/// Alias template for enable_if
template<bool _Cond, typename _Tp = void>
using enable_if_t = typename enable_if<_Cond, _Tp>::type;
/// Alias template for conditional
template<bool _Cond, typename _Iftrue, typename _Iffalse>
using conditional_t = typename conditional<_Cond, _Iftrue, _Iffalse>::type;
/// Alias template for common_type
template<typename... _Tp>
using common_type_t = typename common_type<_Tp...>::type;
/// Alias template for underlying_type
template<typename _Tp>
using underlying_type_t = typename underlying_type<_Tp>::type;
/// Alias template for result_of
template<typename _Tp>
using result_of_t = typename result_of<_Tp>::type;
#endif
/// @} group metaprogramming
/**
......
// { 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
// <http://www.gnu.org/licenses/>.
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
using namespace std;
static_assert( is_same<typename add_lvalue_reference<long>::type,
add_lvalue_reference_t<long>>(),
"add_lvalue_reference_t" );
// { 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
// <http://www.gnu.org/licenses/>.
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
using namespace std;
static_assert( is_same<typename add_rvalue_reference<long>::type,
add_rvalue_reference_t<long>>(),
"add_rvalue_reference_t" );
// { dg-options "-std=gnu++0x" }
// { dg-options "-std=gnu++11" }
// { dg-do compile }
// 2009-11-12 Paolo Carlini <paolo.carlini@oracle.com>
//
// Copyright (C) 2009-2013 Free Software Foundation, Inc.
......@@ -19,53 +20,53 @@
// <http://www.gnu.org/licenses/>.
#include <type_traits>
#include <testsuite_hooks.h>
// DR 1255.
void test01()
{
bool test __attribute__((unused)) = true;
using std::common_type;
using std::is_same;
VERIFY( (is_same<common_type<void>::type, void>::value) );
VERIFY( (is_same<common_type<const void>::type, void>::value) );
VERIFY( (is_same<common_type<volatile void>::type, void>::value) );
VERIFY( (is_same<common_type<const volatile void>::type, void>::value) );
static_assert( is_same<common_type<void>::type, void>(),
"common_type<void>" );
static_assert( is_same<common_type<const void>::type, void>(),
"common_type<const void>" );
static_assert( is_same<common_type<volatile void>::type, void>(),
"common_type<volatile void>" );
static_assert( is_same<common_type<const volatile void>::type, void>(),
"common_type<const volatile void>" );
VERIFY( (is_same<common_type<void, void>::type, void>::value) );
VERIFY( (is_same<common_type<void, const void>::type, void>::value) );
VERIFY( (is_same<common_type<void, volatile void>::type, void>::value) );
VERIFY( (is_same<common_type<void, const volatile void>::type,
void>::value) );
VERIFY( (is_same<common_type<const void, void>::type,
void>::value) );
VERIFY( (is_same<common_type<const void, const void>::type,
void>::value) );
VERIFY( (is_same<common_type<const void, volatile void>::type,
void>::value) );
VERIFY( (is_same<common_type<const void, const volatile void>::type,
void>::value) );
VERIFY( (is_same<common_type<volatile void, void>::type,
void>::value) );
VERIFY( (is_same<common_type<volatile void, volatile void>::type,
void>::value) );
VERIFY( (is_same<common_type<volatile void, const void>::type,
void>::value) );
VERIFY( (is_same<common_type<volatile void, const volatile void>::type,
void>::value) );
VERIFY( (is_same<common_type<const volatile void, void>::type,
void>::value) );
VERIFY( (is_same<common_type<const volatile void, const void>::type,
void>::value) );
VERIFY( (is_same<common_type<const volatile void, volatile void>::type,
void>::value) );
VERIFY( (is_same<common_type<const volatile void, const volatile void>::type,
void>::value) );
}
int main()
{
test01();
return 0;
static_assert( is_same<common_type<void, void>::type, void>(),
"common_type<void, void>" );
static_assert( is_same<common_type<void, const void>::type, void>(),
"common_type<void, const void>" );
static_assert( is_same<common_type<void, volatile void>::type, void>(),
"common_type<void, volatile void>" );
static_assert( is_same<common_type<void, const volatile void>::type, void>(),
"common_type<void, const volatile void>" );
static_assert( is_same<common_type<const void, void>::type, void>(),
"common_type<const void, void>" );
static_assert( is_same<common_type<const void, const void>::type, void>(),
"common_type<const void, const void>" );
static_assert( is_same<common_type<const void, volatile void>::type, void>(),
"common_type<const void, volatile void>" );
static_assert( is_same<common_type<const void, const volatile void>::type,
void>(), "common_type<const void, const volatile void>" );
static_assert( is_same<common_type<volatile void, void>::type, void>(),
"common_type<volatile void, void>" );
static_assert( is_same<common_type<volatile void, volatile void>::type,
void>(), "common_type<volatile void, volatile void>" );
static_assert( is_same<common_type<volatile void, const void>::type,
void>(), "common_type<volatile void, const void>" );
static_assert( is_same<common_type<volatile void, const volatile void>::type,
void>(), "common_type<volatile void, const volatile void>" );
static_assert( is_same<common_type<const volatile void, void>::type, void>(),
"common_type<const volatile void, const volatile void>" );
static_assert( is_same<common_type<const volatile void, const void>::type,
void>(), "common_type<const volatile void, const void>" );
static_assert( is_same<common_type<const volatile void, volatile void>::type,
void>(), "common_type<const volatile void, volatile void>" );
static_assert( is_same<common_type<const volatile void, const volatile void>::type,
void>(),
"common_type<const volatile void, const volatile void>" );
}
// { 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
// <http://www.gnu.org/licenses/>.
#include <type_traits>
using namespace std;
static_assert( is_same<common_type<int, long, char, unsigned>::type,
common_type_t<int, long, char, unsigned>>(),
"common_type_t" );
// { 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
// <http://www.gnu.org/licenses/>.
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
using namespace std;
static_assert( is_same<typename conditional<true, long, void>::type,
conditional_t<true, long, void>>(),
"conditional_t<true, ...>" );
static_assert( is_same<typename conditional<false, long, void>::type,
conditional_t<false, long, void>>(),
"conditional_t<false, ...>" );
// { 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
// <http://www.gnu.org/licenses/>.
#include <type_traits>
using namespace std;
template<typename Trait, typename Result>
using test = is_same<typename Trait::type, Result>;
static_assert( test<decay<bool>, decay_t<bool>>(), "decay<bool>" );
static_assert( test<decay<const int>, decay_t<const int>>(),
"decay<const int>" );
static_assert( test<decay<int[4]>, decay_t<int[4]>>(), "decay<int[4]>" );
typedef void (fn_type) ();
static_assert( test<decay<fn_type>, decay_t<fn_type>>(), "decay<fn_type>" );
typedef void (cfn_type) () const;
static_assert( test<decay<cfn_type>, decay_t<cfn_type>>(), "decay<cfn_type>" );
// { dg-options "-std=gnu++0x" }
// { dg-options "-std=gnu++11" }
// { dg-do compile }
// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com>
//
......@@ -19,38 +20,31 @@
// with this library; see the file COPYING3. If not see
// <http://www.gnu.org/licenses/>.
#include <cstdlib>
#include <type_traits>
#include <testsuite_hooks.h>
void test01()
{
bool test __attribute__((unused)) = true;
using std::decay;
using std::is_same;
// Positive tests.
typedef decay<bool>::type test1_type;
VERIFY( (is_same<test1_type, bool>::value) );
static_assert( is_same<test1_type, bool>(), "decay<bool>" );
// NB: DR 705.
typedef decay<const int>::type test2_type;
VERIFY( (is_same<test2_type, int>::value) );
static_assert( is_same<test2_type, int>(), "decay<const int>" );
typedef decay<int[4]>::type test3_type;
VERIFY( (is_same<test3_type, std::remove_extent<int[4]>::type*>::value) );
static_assert( is_same<test3_type, std::remove_extent<int[4]>::type*>(),
"decay<int[4]>" );
typedef void (fn_type) ();
typedef decay<fn_type>::type test4_type;
VERIFY( (is_same<test4_type, std::add_pointer<fn_type>::type>::value) );
static_assert( is_same<test4_type, std::add_pointer<fn_type>::type>(),
"decay<fn_type>" );
typedef void (cfn_type) () const;
typedef decay<cfn_type>::type test5_type;
VERIFY( (is_same<test5_type, cfn_type>::value) );
}
int main()
{
test01();
return 0;
static_assert( is_same<test5_type, cfn_type>(), "decay<cfn_type>" );
}
......@@ -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 *-*-* } 1938 }
// { dg-error "static assertion failed" "" { target *-*-* } 2003 }
#include <utility>
......
// { 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
// <http://www.gnu.org/licenses/>.
#include <type_traits>
using namespace std;
static_assert( is_same<enable_if<true>::type, enable_if_t<true>>(),
"enable_if_t<true>" );
struct X;
static_assert( is_same<enable_if<true, X>::type, enable_if_t<true, X>>(),
"enable_if_t<true, X>" );
// { dg-options "-std=gnu++0x" }
// { dg-options "-std=gnu++11" }
// { dg-do compile }
// 2007-05-03 Benjamin Kosnik <bkoz@redhat.com>
//
......@@ -20,55 +21,57 @@
// <http://www.gnu.org/licenses/>.
#include <type_traits>
#include <testsuite_hooks.h>
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<const int>::type test2_type;
VERIFY( (is_same<test2_type, const int>::value) );
static_assert( is_same<test2_type, const int>::value,
"make_signed<const int>" );
typedef make_signed<const unsigned int>::type test21c_type;
VERIFY( (is_same<test21c_type, const signed int>::value) );
static_assert( is_same<test21c_type, const signed int>::value,
"make_signed<const unsigned int>" );
typedef make_signed<volatile unsigned int>::type test21v_type;
VERIFY( (is_same<test21v_type, volatile signed int>::value) );
static_assert( is_same<test21v_type, volatile signed int>::value,
"make_signed<volatile unsigned int>" );
typedef make_signed<const volatile unsigned int>::type test21cv_type;
VERIFY( (is_same<test21cv_type, const volatile signed int>::value) );
static_assert( is_same<test21cv_type, const volatile signed int>::value,
"make_signed<const volatile unsigned int>" );
typedef make_signed<const char>::type test22_type;
VERIFY( (is_same<test22_type, const signed char>::value) );
static_assert( is_same<test22_type, const signed char>::value,
"make_signed<const char>" );
#ifdef _GLIBCXX_USE_WCHAR_T
typedef make_signed<volatile wchar_t>::type test23_type;
VERIFY( (is_same<test23_type, volatile signed wchar_t>::value) );
static_assert( is_same<test23_type, volatile signed wchar_t>::value,
"make_signed<volatile wchar_t>" );
#endif
// Chapter 48, chapter 20. Smallest rank such that new signed type same size.
typedef make_signed<test_enum>::type test24_type;
VERIFY( is_signed<test24_type>::value );
VERIFY( sizeof(test24_type) == sizeof(test_enum) );
static_assert( is_signed<test24_type>::value,
"make_signed<test_enum> makes signed type" );
static_assert( sizeof(test24_type) == sizeof(test_enum),
"make_signed<test_enum> makes type of same size" );
// GNU Extensions.
#ifdef _GLIBCXX_USE_INT128
typedef make_signed<unsigned __int128>::type test25_type;
VERIFY( (is_same<test25_type, __int128>::value) );
static_assert( is_same<test25_type, __int128>::value,
"make_signed<unsigned __int128>" );
typedef make_signed<__int128>::type test26_type;
VERIFY( (is_same<test26_type, __int128>::value) );
static_assert( is_same<test26_type, __int128>::value,
"make_signed<__int128>" );
#endif
}
int main()
{
test01();
return 0;
}
// { 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
// <http://www.gnu.org/licenses/>.
#include <type_traits>
using namespace std;
template<typename Trait, typename Result>
using test = is_same<typename Trait::type, Result>;
static_assert( test<make_signed<const int>, make_signed_t<const int>>(),
"make_signed_t<const int>" );
static_assert( test<make_signed<unsigned>, make_signed_t<unsigned>>(),
"make_signed_t<unsigned>" );
static_assert( test<make_signed<char>, make_signed_t<char>>(),
"make_signed_t<char>" );
......@@ -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 }
// { 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
// <http://www.gnu.org/licenses/>.
#include <type_traits>
using namespace std;
template<typename Trait, typename Result>
using test = is_same<typename Trait::type, Result>;
static_assert( test<make_unsigned<const int>, make_unsigned_t<const int>>(),
"make_unsigned_t<const int>" );
static_assert( test<make_unsigned<unsigned>, make_unsigned_t<unsigned>>(),
"make_unsigned_t<unsigned>" );
static_assert( test<make_unsigned<char>, make_unsigned_t<char>>(),
"make_unsigned_t<char>" );
......@@ -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 }
// { 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
// <http://www.gnu.org/licenses/>.
#include <type_traits>
using namespace std;
static_assert( is_same<remove_reference<int>::type, remove_reference_t<int>>(),
"remove_reference_t<int>" );
static_assert( is_same<remove_reference<int&>::type, remove_reference_t<int&>>(),
"remove_reference_t<int&>" );
static_assert( is_same<remove_reference<int&&>::type, remove_reference_t<int&&>>(),
"remove_reference_t<int&&>" );
// { 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
// <http://www.gnu.org/licenses/>.
#include <type_traits>
using namespace std;
using F1 = char(*)(char);
static_assert( is_same<result_of<F1(int)>::type, result_of_t<F1(int)>>(),
"result_of_t<F1(int)>" );
struct X { };
using F2 = int X::*;
static_assert( is_same<result_of<F2(X)>::type, result_of_t<F2(X)>>(),
"result_of_t<F2(X)>" );
// { 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
// <http://www.gnu.org/licenses/>.
//
// NB: This file is for testing type_traits with NO OTHER INCLUDES.
#include <type_traits>
using namespace std;
enum E : long { };
static_assert( is_same<typename underlying_type<E>::type,
underlying_type_t<E>>(),
"underlying_type_t" );
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