From 123c516a9ee069efe6783682ff0bfbf28ec94919 Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Wed, 13 Apr 2011 22:52:45 +0000 Subject: [PATCH] [multiple changes] 2011-04-13 Daniel Krugler Paolo Carlini PR libstdc++/48526 * include/std/type_traits (struct is_constructible): Re-implement, according to n3290. (struct is_default_constructible): Add. (struct is_destructible): Likewise. (struct __and_, __or_, __not_): Add and use throughout; reorder some facilities, other minor tweaks. * testsuite/util/testsuite_tr1.h: Add test types. * testsuite/20_util/is_constructible/value-2.cc: New. * testsuite/20_util/is_default_constructible/value.cc: Likewise. * testsuite/20_util/is_default_constructible/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_default_constructible/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/is_destructible/value.cc: Likewise. * testsuite/20_util/is_destructible/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_destructible/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust dg-error line numbers. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Likewise. * testsuite/20_util/declval/requirements/1_neg.cc: Likewise. * testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Likewise. 2011-04-13 Paolo Carlini * testsuite/20_util/is_function/value.cc: Add, adapted from the tr testsuite. * testsuite/20_util/is_function/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_function/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/is_function/24808.cc: Likewise. * testsuite/20_util/is_function/35637.cc: Likewise. * testsuite/20_util/is_object/value.cc: Likewise. * testsuite/20_util/is_object/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_object/requirements/explicit_instantiation.cc: : Likewise. * testsuite/20_util/is_object/24808.cc: Likewise. * testsuite/20_util/is_compound/value.cc: Likewise. * testsuite/20_util/is_compound/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_compound/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/is_member_object_pointer/value.cc: Likewise. * testsuite/20_util/is_member_object_pointer/requirements/ typedefs.cc: Likewise. * testsuite/20_util/is_member_object_pointer/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/is_fundamental/value.cc: Likewise. * testsuite/20_util/is_fundamental/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_fundamental/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/is_member_pointer/value.cc: Likewise. * testsuite/20_util/is_member_pointer/requirements/typedefs.cc: Likewise. * testsuite/20_util/is_member_pointer/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/is_member_function_pointer/value.cc: Likewise. * testsuite/20_util/is_member_function_pointer/ requirements/typedefs.cc: Likewise. * testsuite/20_util/is_member_function_pointer/requirements/ explicit_instantiation.cc: Likewise. * testsuite/20_util/is_convertible/value.cc: Minor tweak, adjust Copyright years. From-SVN: r172401 --- libstdc++-v3/ChangeLog | 70 + libstdc++-v3/include/std/type_traits | 1230 +++++++++++------ .../20_util/declval/requirements/1_neg.cc | 2 +- .../requirements/explicit_instantiation.cc | 29 + .../is_compound/requirements/typedefs.cc | 34 + .../testsuite/20_util/is_compound/value.cc | 57 + .../20_util/is_constructible/value-2.cc | 819 +++++++++++ .../testsuite/20_util/is_convertible/value.cc | 6 +- .../requirements/explicit_instantiation.cc | 29 + .../requirements/typedefs.cc | 36 + .../20_util/is_default_constructible/value.cc | 134 ++ .../requirements/explicit_instantiation.cc | 29 + .../is_destructible/requirements/typedefs.cc | 36 + .../20_util/is_destructible/value.cc | 100 ++ .../testsuite/20_util/is_function/24808.cc | 38 + .../testsuite/20_util/is_function/35637.cc | 32 + .../requirements/explicit_instantiation.cc | 29 + .../is_function/requirements/typedefs.cc | 34 + .../testsuite/20_util/is_function/value.cc | 52 + .../requirements/explicit_instantiation.cc | 29 + .../is_fundamental/requirements/typedefs.cc | 34 + .../testsuite/20_util/is_fundamental/value.cc | 57 + .../requirements/explicit_instantiation.cc | 29 + .../requirements/typedefs.cc | 34 + .../is_member_function_pointer/value.cc | 58 + .../requirements/explicit_instantiation.cc | 29 + .../requirements/typedefs.cc | 34 + .../20_util/is_member_object_pointer/value.cc | 58 + .../requirements/explicit_instantiation.cc | 29 + .../requirements/typedefs.cc | 34 + .../20_util/is_member_pointer/value.cc | 53 + .../testsuite/20_util/is_object/24808.cc | 38 + .../requirements/explicit_instantiation.cc | 29 + .../is_object/requirements/typedefs.cc | 36 + .../testsuite/20_util/is_object/value.cc | 47 + .../make_signed/requirements/typedefs_neg.cc | 6 +- .../requirements/typedefs_neg.cc | 4 +- .../20_util/ratio/cons/cons_overflow_neg.cc | 2 +- libstdc++-v3/testsuite/util/testsuite_tr1.h | 126 +- 39 files changed, 3122 insertions(+), 440 deletions(-) create mode 100644 libstdc++-v3/testsuite/20_util/is_compound/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_compound/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_compound/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_destructible/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_destructible/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_destructible/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_function/24808.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_function/35637.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_function/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_function/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_function/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_fundamental/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_fundamental/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_fundamental/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_member_function_pointer/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_member_object_pointer/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_member_pointer/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_object/24808.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_object/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_object/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/is_object/value.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 48b27d64657..eb87a87ce4c 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,73 @@ +2011-04-13 Daniel Krugler + Paolo Carlini + + PR libstdc++/48526 + * include/std/type_traits (struct is_constructible): Re-implement, + according to n3290. + (struct is_default_constructible): Add. + (struct is_destructible): Likewise. + (struct __and_, __or_, __not_): Add and use throughout; reorder some + facilities, other minor tweaks. + * testsuite/util/testsuite_tr1.h: Add test types. + * testsuite/20_util/is_constructible/value-2.cc: New. + * testsuite/20_util/is_default_constructible/value.cc: Likewise. + * testsuite/20_util/is_default_constructible/requirements/typedefs.cc: + Likewise. + * testsuite/20_util/is_default_constructible/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/is_destructible/value.cc: Likewise. + * testsuite/20_util/is_destructible/requirements/typedefs.cc: + Likewise. + * testsuite/20_util/is_destructible/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Adjust + dg-error line numbers. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: + Likewise. + * testsuite/20_util/declval/requirements/1_neg.cc: Likewise. + * testsuite/20_util/ratio/cons/cons_overflow_neg.cc: Likewise. + +2011-04-13 Paolo Carlini + + * testsuite/20_util/is_function/value.cc: Add, adapted from the tr + testsuite. + * testsuite/20_util/is_function/requirements/typedefs.cc: Likewise. + * testsuite/20_util/is_function/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/is_function/24808.cc: Likewise. + * testsuite/20_util/is_function/35637.cc: Likewise. + * testsuite/20_util/is_object/value.cc: Likewise. + * testsuite/20_util/is_object/requirements/typedefs.cc: Likewise. + * testsuite/20_util/is_object/requirements/explicit_instantiation.cc: + : Likewise. + * testsuite/20_util/is_object/24808.cc: Likewise. + * testsuite/20_util/is_compound/value.cc: Likewise. + * testsuite/20_util/is_compound/requirements/typedefs.cc: Likewise. + * testsuite/20_util/is_compound/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/is_member_object_pointer/value.cc: Likewise. + * testsuite/20_util/is_member_object_pointer/requirements/ + typedefs.cc: Likewise. + * testsuite/20_util/is_member_object_pointer/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/is_fundamental/value.cc: Likewise. + * testsuite/20_util/is_fundamental/requirements/typedefs.cc: Likewise. + * testsuite/20_util/is_fundamental/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/is_member_pointer/value.cc: Likewise. + * testsuite/20_util/is_member_pointer/requirements/typedefs.cc: + Likewise. + * testsuite/20_util/is_member_pointer/requirements/ + explicit_instantiation.cc: Likewise. + * testsuite/20_util/is_member_function_pointer/value.cc: Likewise. + * testsuite/20_util/is_member_function_pointer/ + requirements/typedefs.cc: Likewise. + * testsuite/20_util/is_member_function_pointer/requirements/ + explicit_instantiation.cc: Likewise. + + * testsuite/20_util/is_convertible/value.cc: Minor tweak, adjust + Copyright years. + 2011-04-12 Takaya Saito PR libstdc++/48476 diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index f5d867b6bfb..a4c76730f5b 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1,6 +1,6 @@ // C++0x type_traits -*- C++ -*- -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010, 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 @@ -51,21 +51,46 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef struct { char __arr[2]; } __two; }; -#define _DEFINE_SPEC_0_HELPER \ - template<> + // Meta programming helper types. -#define _DEFINE_SPEC_1_HELPER \ - template + template + struct conditional; -#define _DEFINE_SPEC_2_HELPER \ - template + template + struct integral_constant; + + template + struct __or_; + + template + struct __or_<_B1, _B2> + : public conditional<_B1::value, _B1, _B2>::type + { }; + + template + struct __or_<_B1, _B2, _B3, _Bn...> + : public conditional<_B1::value, _B1, __or_<_B2, _B3, _Bn...>>::type + { }; -#define _DEFINE_SPEC(_Order, _Trait, _Type, _Value) \ - _DEFINE_SPEC_##_Order##_HELPER \ - struct _Trait<_Type> \ - : public integral_constant { }; + template + struct __and_; - // helper classes. + template + struct __and_<_B1, _B2> + : public conditional<_B1::value, _B2, _B1>::type + { }; + + template + struct __and_<_B1, _B2, _B3, _Bn...> + : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type + { }; + + template + struct __not_ + : public integral_constant + { }; + + // helper class. /// integral_constant template @@ -86,16 +111,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template constexpr _Tp integral_constant<_Tp, __v>::value; - /// remove_cv + // primary type categories. + template struct remove_cv; template struct __is_void_helper : public false_type { }; - _DEFINE_SPEC(0, __is_void_helper, void, true) - // primary type categories. + template<> + struct __is_void_helper + : public true_type { }; /// is_void template @@ -107,23 +134,68 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_integral_helper : public false_type { }; - _DEFINE_SPEC(0, __is_integral_helper, bool, true) - _DEFINE_SPEC(0, __is_integral_helper, char, true) - _DEFINE_SPEC(0, __is_integral_helper, signed char, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned char, true) + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + #ifdef _GLIBCXX_USE_WCHAR_T - _DEFINE_SPEC(0, __is_integral_helper, wchar_t, true) + template<> + struct __is_integral_helper + : public true_type { }; #endif - _DEFINE_SPEC(0, __is_integral_helper, char16_t, true) - _DEFINE_SPEC(0, __is_integral_helper, char32_t, true) - _DEFINE_SPEC(0, __is_integral_helper, short, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned short, true) - _DEFINE_SPEC(0, __is_integral_helper, int, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned int, true) - _DEFINE_SPEC(0, __is_integral_helper, long, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned long, true) - _DEFINE_SPEC(0, __is_integral_helper, long long, true) - _DEFINE_SPEC(0, __is_integral_helper, unsigned long long, true) + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; + + template<> + struct __is_integral_helper + : public true_type { }; /// is_integral template @@ -135,9 +207,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_floating_point_helper : public false_type { }; - _DEFINE_SPEC(0, __is_floating_point_helper, float, true) - _DEFINE_SPEC(0, __is_floating_point_helper, double, true) - _DEFINE_SPEC(0, __is_floating_point_helper, long double, true) + + template<> + struct __is_floating_point_helper + : public true_type { }; + + template<> + struct __is_floating_point_helper + : public true_type { }; + + template<> + struct __is_floating_point_helper + : public true_type { }; /// is_floating_point template @@ -162,7 +243,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_pointer_helper : public false_type { }; - _DEFINE_SPEC(1, __is_pointer_helper, _Tp*, true) + + template + struct __is_pointer_helper<_Tp*> + : public true_type { }; /// is_pointer template @@ -171,19 +255,34 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION remove_cv<_Tp>::type>::value)> { }; - /// is_reference + /// is_lvalue_reference + template + struct is_lvalue_reference + : public false_type { }; + template - struct is_reference; + struct is_lvalue_reference<_Tp&> + : public true_type { }; + + /// is_rvalue_reference + template + struct is_rvalue_reference + : public false_type { }; - /// is_function template + struct is_rvalue_reference<_Tp&&> + : public true_type { }; + + template struct is_function; template struct __is_member_object_pointer_helper : public false_type { }; - _DEFINE_SPEC(2, __is_member_object_pointer_helper, _Tp _Cp::*, - !is_function<_Tp>::value) + + template + struct __is_member_object_pointer_helper<_Tp _Cp::*> + : public integral_constant::value> { }; /// is_member_object_pointer template @@ -195,8 +294,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_member_function_pointer_helper : public false_type { }; - _DEFINE_SPEC(2, __is_member_function_pointer_helper, _Tp _Cp::*, - is_function<_Tp>::value) + + template + struct __is_member_function_pointer_helper<_Tp _Cp::*> + : public integral_constant::value> { }; /// is_member_function_pointer template @@ -227,27 +328,35 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct is_function : public false_type { }; + template struct is_function<_Res(_ArgTypes...)> : public true_type { }; + template struct is_function<_Res(_ArgTypes......)> : public true_type { }; + template struct is_function<_Res(_ArgTypes...) const> : public true_type { }; + template struct is_function<_Res(_ArgTypes......) const> : public true_type { }; + template struct is_function<_Res(_ArgTypes...) volatile> : public true_type { }; + template struct is_function<_Res(_ArgTypes......) volatile> : public true_type { }; + template struct is_function<_Res(_ArgTypes...) const volatile> : public true_type { }; + template struct is_function<_Res(_ArgTypes......) const volatile> : public true_type { }; @@ -255,7 +364,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_nullptr_t_helper : public false_type { }; - _DEFINE_SPEC(0, __is_nullptr_t_helper, std::nullptr_t, true) + + template<> + struct __is_nullptr_t_helper + : public true_type { }; // __is_nullptr_t (extension). template @@ -264,42 +376,42 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION remove_cv<_Tp>::type>::value)> { }; - // composite type traits. - + // composite type categories. + + /// is_reference + template + struct is_reference + : public __or_, + is_rvalue_reference<_Tp>>::type + { }; + /// is_arithmetic template struct is_arithmetic - : public integral_constant::value - || is_floating_point<_Tp>::value)> + : public __or_, is_floating_point<_Tp>>::type { }; /// is_fundamental template struct is_fundamental - : public integral_constant::value - || is_void<_Tp>::value)> + : public __or_, is_void<_Tp>>::type { }; /// is_object template struct is_object - : public integral_constant::value - || is_reference<_Tp>::value - || is_void<_Tp>::value)> + : public __not_<__or_, is_reference<_Tp>, + is_void<_Tp>>>::type { }; - /// is_member_pointer - template + template struct is_member_pointer; /// is_scalar template struct is_scalar - : public integral_constant::value - || is_enum<_Tp>::value - || is_pointer<_Tp>::value - || is_member_pointer<_Tp>::value - || __is_nullptr_t<_Tp>::value)> + : public __or_, is_enum<_Tp>, is_pointer<_Tp>, + is_member_pointer<_Tp>, __is_nullptr_t<_Tp>>::type { }; /// is_compound @@ -311,15 +423,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_member_pointer_helper : public false_type { }; - _DEFINE_SPEC(2, __is_member_pointer_helper, _Tp _Cp::*, true) + + template + struct __is_member_pointer_helper<_Tp _Cp::*> + : public true_type { }; template - struct is_member_pointer + struct is_member_pointer : public integral_constant::type>::value)> { }; // type properties. + /// is_const template struct is_const @@ -338,6 +454,33 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct is_volatile<_Tp volatile> : public true_type { }; + /// is_trivial + template + struct is_trivial + : public integral_constant + { }; + + /// is_trivially_copyable (still unimplemented) + + /// is_standard_layout + template + struct is_standard_layout + : public integral_constant + { }; + + /// is_pod + // Could use is_standard_layout && is_trivial instead of the builtin. + template + struct is_pod + : public integral_constant + { }; + + /// is_literal_type + template + struct is_literal_type + : public integral_constant + { }; + /// is_empty template struct is_empty @@ -356,336 +499,362 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public integral_constant { }; - /// has_virtual_destructor + template::value, + bool = is_floating_point<_Tp>::value> + struct __is_signed_helper + : public false_type { }; + template - struct has_virtual_destructor - : public integral_constant + struct __is_signed_helper<_Tp, false, true> + : public true_type { }; + + template + struct __is_signed_helper<_Tp, true, false> + : public integral_constant(_Tp(-1) < _Tp(0))> { }; - /// alignment_of + /// is_signed template - struct alignment_of - : public integral_constant { }; - - /// rank + struct is_signed + : public integral_constant::value> + { }; + + /// is_unsigned + template + struct is_unsigned + : public __and_, __not_>>::type + { }; + + + // destructible and constructible type properties + template - struct rank - : public integral_constant { }; - - template - struct rank<_Tp[_Size]> - : public integral_constant::value> { }; + struct add_rvalue_reference; template - struct rank<_Tp[]> - : public integral_constant::value> { }; + typename add_rvalue_reference<_Tp>::type declval() noexcept; - /// extent - template - struct extent - : public integral_constant { }; - - template - struct extent<_Tp[_Size], _Uint> - : public integral_constant::value> + template + struct extent; + + template + struct remove_all_extents; + + template + struct __is_array_known_bounds + : public integral_constant::value > 0)> { }; - template - struct extent<_Tp[], _Uint> - : public integral_constant::value> + template + struct __is_array_unknown_bounds + : public __and_, __not_>>::type { }; - // relationships between types [4.6]. + struct __do_is_destructible_impl_1 + { + template + struct __w { _Up __u; }; - /// is_same - template - struct is_same - : public false_type { }; + template&>().~__w<_Tp>())> + static true_type __test(int); + + template + static false_type __test(...); + }; template - struct is_same<_Tp, _Tp> - : public true_type { }; + struct __is_destructible_impl_1 + : public __do_is_destructible_impl_1 + { + typedef decltype(__test<_Tp>(0)) type; + }; - // const-volatile modifications [4.7.1]. + struct __do_is_destructible_impl_2 + { + template().~_Tp())> + static true_type __test(int); + + template + static false_type __test(...); + }; - /// remove_const template - struct remove_const - { typedef _Tp type; }; + struct __is_destructible_impl_2 + : public __do_is_destructible_impl_2 + { + typedef decltype(__test<_Tp>(0)) type; + }; + + template, + __is_array_unknown_bounds<_Tp>>::value, + bool = __or_, is_function<_Tp>>::value> + struct __is_destructible_safe; template - struct remove_const<_Tp const> - { typedef _Tp type; }; - - /// remove_volatile + struct __is_destructible_safe<_Tp, false, false> + : public conditional::value, + __is_destructible_impl_2<_Tp>, + __is_destructible_impl_1<_Tp>>::type::type + { }; + template - struct remove_volatile - { typedef _Tp type; }; + struct __is_destructible_safe<_Tp, true, false> + : public false_type { }; template - struct remove_volatile<_Tp volatile> - { typedef _Tp type; }; - - /// remove_cv + struct __is_destructible_safe<_Tp, false, true> + : public true_type { }; + + /// is_destructible template - struct remove_cv + struct is_destructible + : public integral_constant::value)> + { }; + + struct __do_is_default_constructible_impl + { + template + static true_type __test(int); + + template + static false_type __test(...); + }; + + template + struct __is_default_constructible_impl + : public __do_is_default_constructible_impl { - typedef typename - remove_const::type>::type type; + typedef decltype(__test<_Tp>(0)) type; }; - - /// add_const - template - struct add_const - { typedef _Tp const type; }; - - /// add_volatile - template - struct add_volatile - { typedef _Tp volatile type; }; - - /// add_cv - template - struct add_cv - { - typedef typename - add_const::type>::type type; - }; - - // array modifications. - - /// remove_extent - template - struct remove_extent - { typedef _Tp type; }; - - template - struct remove_extent<_Tp[_Size]> - { typedef _Tp type; }; - - template - struct remove_extent<_Tp[]> - { typedef _Tp type; }; - - /// remove_all_extents - template - struct remove_all_extents - { typedef _Tp type; }; - - template - struct remove_all_extents<_Tp[_Size]> - { typedef typename remove_all_extents<_Tp>::type type; }; template - struct remove_all_extents<_Tp[]> - { typedef typename remove_all_extents<_Tp>::type type; }; - - // pointer modifications. + struct __is_default_constructible_atom + : public __and_, + __is_default_constructible_impl<_Tp>>::type::type + { }; - template - struct __remove_pointer_helper - { typedef _Tp type; }; + template::value> + struct __is_default_constructible_safe; - template - struct __remove_pointer_helper<_Tp, _Up*> - { typedef _Up type; }; + // The following technique is a workaround for a gcc defect, which does + // not sfinae away attempts to default-construct arrays of unknown bounds. + // Complete arrays can be default-constructed, if the element type is + // default-constructible, but arrays with unknown bounds are not: - /// remove_pointer template - struct remove_pointer - : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> + struct __is_default_constructible_safe<_Tp, true> + : public __and_<__is_array_known_bounds<_Tp>, + __is_default_constructible_atom::type>>::type::type { }; - template - struct remove_reference; - - /// add_pointer template - struct add_pointer - { typedef typename remove_reference<_Tp>::type* type; }; - - // Primary classification traits. - - /// is_lvalue_reference - template - struct is_lvalue_reference - : public false_type { }; + struct __is_default_constructible_safe<_Tp, false> + : public __is_default_constructible_atom<_Tp>::type + { }; + /// is_default_constructible template - struct is_lvalue_reference<_Tp&> - : public true_type { }; + struct is_default_constructible + : public integral_constant::value)> + { }; - /// is_rvalue_reference - template - struct is_rvalue_reference - : public false_type { }; + struct __do_is_static_castable_impl + { + template(declval<_From>()))> + static true_type __test(int); - template - struct is_rvalue_reference<_Tp&&> - : public true_type { }; + template + static false_type __test(...); + }; - // Secondary classification traits. + template + struct __is_static_castable_impl + : public __do_is_static_castable_impl + { + typedef decltype(__test<_From, _To>(0)) type; + }; - /// is_reference - template - struct is_reference - : public integral_constant::value - || is_rvalue_reference<_Tp>::value)> + template + struct __is_static_castable_safe + : public __and_<__or_, is_destructible<_To>>, + __is_static_castable_impl<_From, _To>>::type::type { }; - // Reference transformations. + // __is_static_castable + template + struct __is_static_castable + : public integral_constant::value)> + { }; - /// remove_reference - template - struct remove_reference - { typedef _Tp type; }; + struct __do_is_direct_constructible_impl + { + template()))> + static true_type __test(int); - template - struct remove_reference<_Tp&> - { typedef _Tp type; }; + template + static false_type __test(...); + }; - template - struct remove_reference<_Tp&&> - { typedef _Tp type; }; + template + struct __is_direct_constructible_impl + : public __do_is_direct_constructible_impl + { + typedef decltype(__test<_Tp, _Arg>(0)) type; + }; - template::value && !is_void<_Tp>::value, - bool = is_rvalue_reference<_Tp>::value> - struct __add_lvalue_reference_helper - { typedef _Tp type; }; + template + struct __is_direct_constructible_new_safe + : public __and_, + __is_direct_constructible_impl<_Tp, _Arg>>::type::type + { }; - template - struct __add_lvalue_reference_helper<_Tp, true, false> - { typedef _Tp& type; }; + template + struct is_same; - template - struct __add_lvalue_reference_helper<_Tp, false, true> - { typedef typename remove_reference<_Tp>::type& type; }; + template + struct is_base_of; - /// add_lvalue_reference - template - struct add_lvalue_reference - : public __add_lvalue_reference_helper<_Tp> - { }; + template + struct remove_reference; - template::value && !is_void<_Tp>::value> - struct __add_rvalue_reference_helper - { typedef _Tp type; }; + template::value> + struct __is_base_to_derived_ref; - template - struct __add_rvalue_reference_helper<_Tp, true> - { typedef _Tp&& type; }; + template + struct __is_base_to_derived_ref<_From, _To, true> + { + typedef typename remove_cv::type>::type __src_t; + typedef typename remove_cv::type>::type __dst_t; + typedef typename __and_< + __not_>, + is_base_of<__src_t, __dst_t> + >::type type; + static constexpr bool value = type::value; + }; - /// add_rvalue_reference - template - struct add_rvalue_reference - : public __add_rvalue_reference_helper<_Tp> + template + struct __is_base_to_derived_ref<_From, _To, false> + : public false_type { }; - // Scalar properties and transformations. - - template::value, - bool = is_floating_point<_Tp>::value> - struct __is_signed_helper - : public false_type { }; + template, + is_rvalue_reference<_To>>::value> + struct __is_lvalue_to_rvalue_ref; - template - struct __is_signed_helper<_Tp, false, true> - : public true_type { }; + template + struct __is_lvalue_to_rvalue_ref<_From, _To, true> + { + typedef typename remove_cv::type>::type __src_t; + typedef typename remove_cv::type>::type __dst_t; + typedef typename __or_< + is_same<__src_t, __dst_t>, + is_base_of<__dst_t, __src_t> + >::type type; + static constexpr bool value = type::value; + }; - template - struct __is_signed_helper<_Tp, true, false> - : public integral_constant(_Tp(-1) < _Tp(0))> + template + struct __is_lvalue_to_rvalue_ref<_From, _To, false> + : public false_type { }; - /// is_signed - template - struct is_signed - : public integral_constant::value> - { }; + // Here we handle direct-initialization to a reference type + // as equivalent to a static_cast modulo overshooting conversions. + // These are restricted to the following conversion: + // a) A base class to a derived class reference + // b) An lvalue-reference to an rvalue-reference - /// is_unsigned - template - struct is_unsigned - : public integral_constant::value - && !is_signed<_Tp>::value)> + template + struct __is_direct_constructible_ref_cast + : public __and_<__is_static_castable<_Arg, _Tp>, + __not_<__or_<__is_base_to_derived_ref<_Arg, _Tp>, + __is_lvalue_to_rvalue_ref<_Arg, _Tp> + >>>::type::type { }; - // Member introspection. - - /// is_trivial - template - struct is_trivial - : public integral_constant - { }; + // Direct-initialization is tricky, because of functional + // casts: For a conversion to reference we fall back to a + // static_cast modulo extra cases, otherwise we use a + // new expression: - /// is_standard_layout - template - struct is_standard_layout - : public integral_constant + template + struct __is_direct_constructible_new + : public conditional::value, + __is_direct_constructible_ref_cast<_Tp, _Arg>, + __is_direct_constructible_new_safe<_Tp, _Arg> + >::type { }; - /// is_pod - // Could use is_standard_layout && is_trivial instead of the builtin. - template - struct is_pod - : public integral_constant + template + struct __is_direct_constructible + : public integral_constant::type::value)> { }; - /// is_literal_type - template - struct is_literal_type - : public integral_constant - { }; + struct __do_is_nary_constructible_impl + { + template()...))> + static true_type __test(int); - template - typename add_rvalue_reference<_Tp>::type declval() noexcept; + template + static false_type __test(...); + }; template - class __is_constructible_helper - : public __sfinae_types + struct __is_nary_constructible_impl + : public __do_is_nary_constructible_impl { - template - static decltype(_Tp1(declval<_Args1>()...), __one()) __test(int); - - template - static __two __test(...); - - public: - static const bool __value = sizeof(__test<_Tp, _Args...>(0)) == 1; + typedef decltype(__test<_Tp, _Args...>(0)) type; }; - template - class __is_constructible_helper<_Tp, _Arg> - : public __sfinae_types + template + struct __is_nary_constructible + : public __and_, + __is_nary_constructible_impl<_Tp, _Args...> + >::type::type { - template - static decltype(static_cast<_Tp1>(declval<_Arg1>()), __one()) - __test(int); + static_assert(sizeof...(_Args) > 1, + "Only useful for > 1 arguments"); + }; - template - static __two __test(...); + template + struct __is_constructible_impl + : public __is_nary_constructible<_Tp, _Args...> + { }; - public: - static const bool __value = sizeof(__test<_Tp, _Arg>(0)) == 1; - }; + template + struct __is_constructible_impl<_Tp, _Arg> + : public __is_direct_constructible<_Tp, _Arg> + { }; + + template + struct __is_constructible_impl<_Tp> + : public is_default_constructible<_Tp> + { }; /// is_constructible - // XXX FIXME - // The C++0x specifications require front-end support, see N2255. template struct is_constructible - : public integral_constant::__value> + : public integral_constant::value)> { }; + template struct __is_nt_constructible_helper { static const bool __value = false; }; @@ -750,7 +919,63 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public integral_constant { }; - // Relationships between types. + /// has_virtual_destructor + template + struct has_virtual_destructor + : public integral_constant + { }; + + + // type property queries. + + /// alignment_of + template + struct alignment_of + : public integral_constant { }; + + /// rank + template + struct rank + : public integral_constant { }; + + template + struct rank<_Tp[_Size]> + : public integral_constant::value> { }; + + template + struct rank<_Tp[]> + : public integral_constant::value> { }; + + /// extent + template + struct extent + : public integral_constant { }; + + template + struct extent<_Tp[_Size], _Uint> + : public integral_constant::value> + { }; + + template + struct extent<_Tp[], _Uint> + : public integral_constant::value> + { }; + + + // type relations. + + /// is_same + template + struct is_same + : public false_type { }; + + template + struct is_same<_Tp, _Tp> + : public true_type { }; /// is_base_of template @@ -759,8 +984,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { }; template::value || is_function<_To>::value - || is_array<_To>::value)> + bool = __or_, is_function<_To>, + is_array<_To>>::value> struct __is_convertible_helper { static const bool __value = is_void<_To>::value; }; @@ -783,8 +1008,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; /// is_convertible - // XXX FIXME - // The C++0x specifications require front-end support, see N2255. template struct is_convertible : public integral_constant { }; - template - struct __aligned_storage_msa - { - union __type - { - unsigned char __data[_Len]; - struct __attribute__((__aligned__)) { } __align; - }; - }; - /** - * @brief Alignment type. - * - * The value of _Align is a default-alignment which shall be the - * most stringent alignment requirement for any C++ object type - * whose size is no greater than _Len (3.9). The member typedef - * type shall be a POD type suitable for use as uninitialized - * storage for any object whose size is at most _Len and whose - * alignment is a divisor of _Align. - */ - template::__type)> - struct aligned_storage - { - union type - { - unsigned char __data[_Len]; - struct __attribute__((__aligned__((_Align)))) { } __align; - }; - }; - - - // Define a nested type if some predicate holds. - // Primary template. - /// enable_if - template - struct enable_if - { }; + // const-volatile modifications. - // Partial specialization for true. + /// remove_const template - struct enable_if - { typedef _Tp type; }; - - - // A conditional expression, but for types. If true, first, if false, second. - // Primary template. - /// conditional - template - struct conditional - { typedef _Iftrue type; }; - - // Partial specialization for false. - template - struct conditional - { typedef _Iffalse type; }; + struct remove_const + { typedef _Tp type; }; + template + struct remove_const<_Tp const> + { typedef _Tp type; }; + + /// remove_volatile + template + struct remove_volatile + { typedef _Tp type; }; - // Decay trait for arrays and functions, used for perfect forwarding - // in make_pair, make_tuple, etc. - template::value, - bool _IsFunction = is_function<_Up>::value> - struct __decay_selector; + template + struct remove_volatile<_Tp volatile> + { typedef _Tp type; }; + + /// remove_cv + template + struct remove_cv + { + typedef typename + remove_const::type>::type type; + }; + + /// add_const + template + struct add_const + { typedef _Tp const type; }; + + /// add_volatile + template + struct add_volatile + { typedef _Tp volatile type; }; + + /// add_cv + template + struct add_cv + { + typedef typename + add_const::type>::type type; + }; - // NB: DR 705. - template - struct __decay_selector<_Up, false, false> - { typedef typename remove_cv<_Up>::type __type; }; - template - struct __decay_selector<_Up, true, false> - { typedef typename remove_extent<_Up>::type* __type; }; + // Reference transformations. - template - struct __decay_selector<_Up, false, true> - { typedef typename add_pointer<_Up>::type __type; }; + /// remove_reference + template + struct remove_reference + { typedef _Tp type; }; - /// decay - template - class decay - { - typedef typename remove_reference<_Tp>::type __remove_type; + template + struct remove_reference<_Tp&> + { typedef _Tp type; }; - public: - typedef typename __decay_selector<__remove_type>::__type type; - }; + template + struct remove_reference<_Tp&&> + { typedef _Tp type; }; + + template>, + __not_>>::value, + bool = is_rvalue_reference<_Tp>::value> + struct __add_lvalue_reference_helper + { typedef _Tp type; }; template - class reference_wrapper; + struct __add_lvalue_reference_helper<_Tp, true, false> + { typedef _Tp& type; }; - // Helper which adds a reference to a type when given a reference_wrapper template - struct __strip_reference_wrapper - { - typedef _Tp __type; - }; + struct __add_lvalue_reference_helper<_Tp, false, true> + { typedef typename remove_reference<_Tp>::type& type; }; + /// add_lvalue_reference template - struct __strip_reference_wrapper > - { - typedef _Tp& __type; - }; + struct add_lvalue_reference + : public __add_lvalue_reference_helper<_Tp> + { }; + + template>, + __not_>>::value> + struct __add_rvalue_reference_helper + { typedef _Tp type; }; template - struct __strip_reference_wrapper > - { - typedef _Tp& __type; - }; + struct __add_rvalue_reference_helper<_Tp, true> + { typedef _Tp&& type; }; + /// add_rvalue_reference template - struct __decay_and_strip - { - typedef typename __strip_reference_wrapper< - typename decay<_Tp>::type>::__type __type; - }; + struct add_rvalue_reference + : public __add_rvalue_reference_helper<_Tp> + { }; + // sign modifications. + // Utility for constructing identically cv-qualified types. template struct __cv_selector; @@ -946,7 +1154,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION typedef typename __match::__type __type; }; - // Utility for finding the unsigned versions of signed integral types. template struct __make_unsigned @@ -976,7 +1183,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __make_unsigned { typedef unsigned long long __type; }; - // Select between integral and enum: not possible to be both. template::value, @@ -1053,7 +1259,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __make_signed { typedef signed long long __type; }; - // Select between integral and enum: not possible to be both. template::value, @@ -1100,6 +1305,176 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template<> struct make_signed; + + // array modifications. + + /// remove_extent + template + struct remove_extent + { typedef _Tp type; }; + + template + struct remove_extent<_Tp[_Size]> + { typedef _Tp type; }; + + template + struct remove_extent<_Tp[]> + { typedef _Tp type; }; + + /// remove_all_extents + template + struct remove_all_extents + { typedef _Tp type; }; + + template + struct remove_all_extents<_Tp[_Size]> + { typedef typename remove_all_extents<_Tp>::type type; }; + + template + struct remove_all_extents<_Tp[]> + { typedef typename remove_all_extents<_Tp>::type type; }; + + + // pointer modifications. + + template + struct __remove_pointer_helper + { typedef _Tp type; }; + + template + struct __remove_pointer_helper<_Tp, _Up*> + { typedef _Up type; }; + + /// remove_pointer + template + struct remove_pointer + : public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type> + { }; + + /// add_pointer + template + struct add_pointer + { typedef typename remove_reference<_Tp>::type* type; }; + + + template + struct __aligned_storage_msa + { + union __type + { + unsigned char __data[_Len]; + struct __attribute__((__aligned__)) { } __align; + }; + }; + + /** + * @brief Alignment type. + * + * The value of _Align is a default-alignment which shall be the + * most stringent alignment requirement for any C++ object type + * whose size is no greater than _Len (3.9). The member typedef + * type shall be a POD type suitable for use as uninitialized + * storage for any object whose size is at most _Len and whose + * alignment is a divisor of _Align. + */ + template::__type)> + struct aligned_storage + { + union type + { + unsigned char __data[_Len]; + struct __attribute__((__aligned__((_Align)))) { } __align; + }; + }; + + + // Decay trait for arrays and functions, used for perfect forwarding + // in make_pair, make_tuple, etc. + template::value, + bool _IsFunction = is_function<_Up>::value> + struct __decay_selector; + + // NB: DR 705. + template + struct __decay_selector<_Up, false, false> + { typedef typename remove_cv<_Up>::type __type; }; + + template + struct __decay_selector<_Up, true, false> + { typedef typename remove_extent<_Up>::type* __type; }; + + template + struct __decay_selector<_Up, false, true> + { typedef typename add_pointer<_Up>::type __type; }; + + /// decay + template + class decay + { + typedef typename remove_reference<_Tp>::type __remove_type; + + public: + typedef typename __decay_selector<__remove_type>::__type type; + }; + + template + class reference_wrapper; + + // Helper which adds a reference to a type when given a reference_wrapper + template + struct __strip_reference_wrapper + { + typedef _Tp __type; + }; + + template + struct __strip_reference_wrapper > + { + typedef _Tp& __type; + }; + + template + struct __strip_reference_wrapper > + { + typedef _Tp& __type; + }; + + template + struct __decay_and_strip + { + typedef typename __strip_reference_wrapper< + typename decay<_Tp>::type>::__type __type; + }; + + + // Define a nested type if some predicate holds. + // Primary template. + /// enable_if + template + struct enable_if + { }; + + // Partial specialization for true. + template + struct enable_if + { typedef _Tp type; }; + + + // A conditional expression, but for types. If true, first, if false, second. + // Primary template. + /// conditional + template + struct conditional + { typedef _Iftrue type; }; + + // Partial specialization for false. + template + struct conditional + { typedef _Iffalse type; }; + + /// common_type template struct common_type; @@ -1119,6 +1494,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION common_type::type, _Vp...>::type type; }; + /// underlying_type (still unimplemented) + + /// result_of + template + class result_of; + + template + struct result_of<_Functor(_ArgTypes...)> + { + typedef + decltype( std::declval<_Functor>()(std::declval<_ArgTypes>()...) ) + type; + }; + /// declval template struct __declval_protector @@ -1136,18 +1525,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return __declval_protector<_Tp>::__delegate(); } - /// result_of - template - class result_of; - - template - struct result_of<_Functor(_ArgTypes...)> - { - typedef - decltype( std::declval<_Functor>()(std::declval<_ArgTypes>()...) ) - type; - }; - /** * Use SFINAE to determine if the type _Tp has a publicly-accessible * member type _NTYPE. @@ -1177,11 +1554,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ::type>::value> \ { }; -#undef _DEFINE_SPEC_0_HELPER -#undef _DEFINE_SPEC_1_HELPER -#undef _DEFINE_SPEC_2_HELPER -#undef _DEFINE_SPEC - // @} group metaprogramming _GLIBCXX_END_NAMESPACE_VERSION } // namespace 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 9113c031be0..aaf1fb029db 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 *-*-* } 1134 } +// { dg-error "static assertion failed" "" { target *-*-* } 1523 } #include diff --git a/libstdc++-v3/testsuite/20_util/is_compound/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_compound/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..efa2b853a1d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_compound/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_compound; +} diff --git a/libstdc++-v3/testsuite/20_util/is_compound/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_compound/requirements/typedefs.cc new file mode 100644 index 00000000000..c167b16b104 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_compound/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { 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 +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_compound test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_compound/value.cc b/libstdc++-v3/testsuite/20_util/is_compound/value.cc new file mode 100644 index 00000000000..053983a2f28 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_compound/value.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_compound; + using namespace __gnu_test; + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category(false)) ); +#endif + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + // Sanity check. + VERIFY( (test_category(true)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc b/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc new file mode 100644 index 00000000000..9e4bd97ef93 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_constructible/value-2.cc @@ -0,0 +1,819 @@ +// { 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 +// . + +#include +#include +#include + +using namespace __gnu_test::construct_destruct; + +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible, + std::initializer_list>::value, "Error"); +static_assert(std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible>::value, "Error"); +static_assert(!std::is_constructible>::value, "Error"); +static_assert(!std::is_constructible>::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible>::value, "Error"); +static_assert(std::is_constructible&>::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible&>::value, "Error"); +static_assert(std::is_constructible>::value, "Error"); +static_assert(std::is_constructible&>::value, "Error"); +static_assert(std::is_constructible>::value, "Error"); + +static_assert(std::is_constructible>::value, "Error"); +static_assert(std::is_constructible&>::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error" ); +static_assert(!std::is_constructible::value, "Error" ); +static_assert(!std::is_constructible::value, "Error" ); + +static_assert(!std::is_constructible::value, "Error" ); +static_assert(!std::is_constructible::value, "Error" ); +static_assert(!std::is_constructible::value, "Error" ); +static_assert(!std::is_constructible::value, "Error" ); + +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, + "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible, int, int>::value, "Error"); +static_assert(!std::is_constructible, int, int>::value, + "Error"); +static_assert(!std::is_constructible, void, int>::value, "Error"); +static_assert(!std::is_constructible, void, int>::value, + "Error"); +static_assert(!std::is_constructible, void, void>::value, "Error"); +static_assert(!std::is_constructible, void, void>::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible&, int, int>::value, "Error"); +static_assert(!std::is_constructible&, void, int>::value, "Error"); +static_assert(!std::is_constructible&, void, void>::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible, int, int>::value, "Error"); +static_assert(!std::is_constructible, int, int>::value, + "Error"); +static_assert(!std::is_constructible, void, int>::value, "Error"); +static_assert(!std::is_constructible, void, int>::value, + "Error"); +static_assert(!std::is_constructible, void, int>::value, + "Error"); +static_assert(!std::is_constructible, void, + int>::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); + +// Deleted members in unions with non-trivial members: +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +// Unusual copy: +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); + +static_assert(std::is_constructible, + int, char>::value, "Error"); +static_assert(std::is_constructible, + int, char>::value, "Error"); +static_assert(std::is_constructible, + int, int>::value, "Error"); +static_assert(std::is_constructible, + int, int>::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible, + ImplicitTo, ImplicitTo>::value, "Error"); +static_assert(std::is_constructible, + ImplicitTo, ImplicitTo>::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible::value, "Error"); +static_assert(std::is_constructible, + std::initializer_list>, std::initializer_list, + std::initializer_list>::value, "Error"); +static_assert(std::is_constructible, + std::initializer_list>, std::initializer_list, + std::initializer_list>::value, "Error"); +static_assert(std::is_constructible, + std::initializer_list>, std::initializer_list&, + std::initializer_list&>::value, "Error"); +static_assert(!std::is_constructible&, + std::initializer_list&>, std::initializer_list, + std::initializer_list>::value, "Error"); + +static_assert(!std::is_constructible>, + int, int>::value, "Error"); +static_assert(!std::is_constructible>, int, int>::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, + "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(!std::is_constructible::value, "Error"); +static_assert(!std::is_constructible::value, "Error"); + +static_assert(std::is_constructible>::value, "Error"); +static_assert(std::is_constructible>::value, + "Error"); +static_assert(std::is_constructible>::value, "Error"); +static_assert(std::is_constructible>::value, + "Error"); + +static_assert(!std::is_constructible>::value, + "Error"); +static_assert(!std::is_constructible>::value, "Error"); + +// Binding through reference-compatible type is required to perform +// direct-initialization as described in [over.match.ref] p. 1 b. 1: +static_assert(std::is_constructible>::value, "Error"); +static_assert(std::is_constructible>::value, + "Error"); +static_assert(std::is_constructible>::value, "Error"); + +// Binding through temporary behaves like copy-initialization, +// see [dcl.init.ref] p. 5, very last sub-bullet: +static_assert(!std::is_constructible>::value, + "Error"); +static_assert(!std::is_constructible>::value, + "Error"); diff --git a/libstdc++-v3/testsuite/20_util/is_convertible/value.cc b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc index fc6007ac555..92ad6607186 100644 --- a/libstdc++-v3/testsuite/20_util/is_convertible/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_convertible/value.cc @@ -2,7 +2,7 @@ // 2009-10-29 Paolo Carlini // -// Copyright (C) 2009 Free Software Foundation, Inc. +// Copyright (C) 2009, 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 @@ -58,6 +58,8 @@ void test01() VERIFY( (test_relationship(true)) ); VERIFY( (test_relationship(true)) ); + VERIFY( (test_relationship(true)) ); + // Negative tests. VERIFY( (test_relationship(false)) ); VERIFY( (test_relationship(false)) ); @@ -93,8 +95,6 @@ void test01() const volatile int&>(false)) ); VERIFY( (test_relationship(false)) ); - VERIFY( (test_relationship(true)) ); - VERIFY( (test_relationship(false)) ); VERIFY( (test_relationship(false)) ); } diff --git a/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..dec86a94ba8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_default_constructible; +} diff --git a/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/typedefs.cc new file mode 100644 index 00000000000..b97d54f2691 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_default_constructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { 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 +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_default_constructible test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc b/libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc new file mode 100644 index 00000000000..bd18d50482d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_default_constructible/value.cc @@ -0,0 +1,134 @@ +// { 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 +// . + +#include +#include +#include + +using namespace __gnu_test::construct_destruct; + +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, + "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, + "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible>::value, "Error"); +static_assert(std::is_default_constructible const>::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible[1]>::value, "Error"); +static_assert(std::is_default_constructible[1]>::value, + "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, + "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible::value, "Error"); +static_assert(std::is_default_constructible>::value, + "Error"); +static_assert(std::is_default_constructible>::value, "Error"); +static_assert(std::is_default_constructible< + std::initializer_list[1]>::value, "Error"); +static_assert(std::is_default_constructible[1]>::value, "Error"); + +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible>::value, "Error"); +static_assert(!std::is_default_constructible>::value, + "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, + "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, + "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible[1]>::value, "Error"); +static_assert(!std::is_default_constructible[1]>::value, + "Error"); +static_assert(!std::is_default_constructible< + FromArgs>>::value, "Error"); +static_assert(!std::is_default_constructible>>::value, "Error"); +static_assert(!std::is_default_constructible>>::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); +static_assert(!std::is_default_constructible::value, "Error"); diff --git a/libstdc++-v3/testsuite/20_util/is_destructible/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_destructible/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..59b59805124 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_destructible/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_destructible; +} diff --git a/libstdc++-v3/testsuite/20_util/is_destructible/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_destructible/requirements/typedefs.cc new file mode 100644 index 00000000000..967842d3ea6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_destructible/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { 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 +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_destructible test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_destructible/value.cc b/libstdc++-v3/testsuite/20_util/is_destructible/value.cc new file mode 100644 index 00000000000..b0382c6e83d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_destructible/value.cc @@ -0,0 +1,100 @@ +// { 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 +// . + +#include +#include +#include + +using namespace __gnu_test::construct_destruct; + +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible>::value, + "Error"); +static_assert(std::is_destructible>::value, + "Error"); +static_assert(std::is_destructible::value, "Error"); +static_assert(std::is_destructible::value, "Error"); + +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); +static_assert(!std::is_destructible::value, "Error"); + +// Deleted members in unions with non-trivial members: +static_assert(!std::is_destructible::value, "Error"); + +// Unusual copy: +static_assert(std::is_destructible::value, "Error"); diff --git a/libstdc++-v3/testsuite/20_util/is_function/24808.cc b/libstdc++-v3/testsuite/20_util/is_function/24808.cc new file mode 100644 index 00000000000..38358e550eb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_function/24808.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } +// +// 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 +// . + +#include +#include +#include + +// libstdc++/24808 +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_function; + using namespace __gnu_test; + + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_function/35637.cc b/libstdc++-v3/testsuite/20_util/is_function/35637.cc new file mode 100644 index 00000000000..52686fbcaf8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_function/35637.cc @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++0x -pedantic-errors" } +// { 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 +// . + +#include + +struct S +{ + void F() const {} +}; + +// libstdc++/35637 +void test01() +{ + std::function a(&S::F); +} diff --git a/libstdc++-v3/testsuite/20_util/is_function/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_function/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..dc340d769cb --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_function/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_function; +} diff --git a/libstdc++-v3/testsuite/20_util/is_function/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_function/requirements/typedefs.cc new file mode 100644 index 00000000000..5b5e35f3af7 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_function/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { 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 +// . + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_function test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_function/value.cc b/libstdc++-v3/testsuite/20_util/is_function/value.cc new file mode 100644 index 00000000000..5f576eb7571 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_function/value.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } +// +// 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_function; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Negative tests. + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..b16826172ba --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_fundamental; +} diff --git a/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/typedefs.cc new file mode 100644 index 00000000000..efb672eaadc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_fundamental/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { 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 +// . + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_fundamental test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_fundamental/value.cc b/libstdc++-v3/testsuite/20_util/is_fundamental/value.cc new file mode 100644 index 00000000000..83091a148fc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_fundamental/value.cc @@ -0,0 +1,57 @@ +// { dg-options "-std=gnu++0x" } +// +// 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_fundamental; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category(true)) ); +#endif + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..304efcca22e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_member_function_pointer; +} diff --git a/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/typedefs.cc new file mode 100644 index 00000000000..2efcdda3635 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_member_function_pointer/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { 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 +// . + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_member_function_pointer test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_member_function_pointer/value.cc b/libstdc++-v3/testsuite/20_util/is_member_function_pointer/value.cc new file mode 100644 index 00000000000..d09c7ca17a9 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_member_function_pointer/value.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_member_function_pointer; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Negative tests. + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..5d2b686adfc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_member_object_pointer; +} diff --git a/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/typedefs.cc new file mode 100644 index 00000000000..13c94b7b472 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_member_object_pointer/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { 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 +// . + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_member_object_pointer test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_member_object_pointer/value.cc b/libstdc++-v3/testsuite/20_util/is_member_object_pointer/value.cc new file mode 100644 index 00000000000..2e004e33c73 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_member_object_pointer/value.cc @@ -0,0 +1,58 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_member_object_pointer; + using namespace __gnu_test; + + // Positive tests. + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Negative tests. + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..f94959e07b6 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_member_pointer; +} diff --git a/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/typedefs.cc new file mode 100644 index 00000000000..9491ee868ff --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_member_pointer/requirements/typedefs.cc @@ -0,0 +1,34 @@ +// { 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 +// . + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +void test01() +{ + // Check for required typedefs + typedef std::is_member_pointer test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_member_pointer/value.cc b/libstdc++-v3/testsuite/20_util/is_member_pointer/value.cc new file mode 100644 index 00000000000..fff9710d5da --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_member_pointer/value.cc @@ -0,0 +1,53 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_member_pointer; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + VERIFY( (test_category(true)) ); + + // Sanity check. + VERIFY( (test_category(false)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_object/24808.cc b/libstdc++-v3/testsuite/20_util/is_object/24808.cc new file mode 100644 index 00000000000..f1fd168a1b5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_object/24808.cc @@ -0,0 +1,38 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// . + +#include +#include +#include + +// libstdc++/24808 +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_object; + using namespace __gnu_test; + + VERIFY( (test_category(true)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/is_object/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/is_object/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..6ee7c4e5a47 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_object/requirements/explicit_instantiation.cc @@ -0,0 +1,29 @@ +// { 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 +// . + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct is_object; +} diff --git a/libstdc++-v3/testsuite/20_util/is_object/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/is_object/requirements/typedefs.cc new file mode 100644 index 00000000000..bec0a8cbd4d --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_object/requirements/typedefs.cc @@ -0,0 +1,36 @@ +// { 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 +// . + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::is_object test_type; + typedef test_type::value_type value_type; + typedef test_type::type type; + typedef test_type::type::value_type type_value_type; + typedef test_type::type::type type_type; +} diff --git a/libstdc++-v3/testsuite/20_util/is_object/value.cc b/libstdc++-v3/testsuite/20_util/is_object/value.cc new file mode 100644 index 00000000000..b3d8df69665 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/is_object/value.cc @@ -0,0 +1,47 @@ +// { dg-options "-std=gnu++0x" } + +// 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 +// . + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::is_object; + using namespace __gnu_test; + + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + VERIFY( (test_category(false)) ); + + // Sanity check. + VERIFY( (test_category(true)) ); +} + +int main() +{ + test01(); + return 0; +} 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 5179abfeb08..4a568e363e8 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 @@ -3,7 +3,7 @@ // 2007-05-03 Benjamin Kosnik // -// Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2007, 2008, 2009, 2010, 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 @@ -48,5 +48,5 @@ void test01() // { dg-error "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1097 } -// { dg-error "declaration of" "" { target *-*-* } 1061 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1302 } +// { dg-error "declaration of" "" { target *-*-* } 1266 } 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 1a1724d74b7..955c1ce00f2 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 "instantiated from here" "" { target *-*-* } 40 } // { dg-error "instantiated from here" "" { target *-*-* } 42 } -// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1020 } -// { dg-error "declaration of" "" { target *-*-* } 984 } +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 1226 } +// { dg-error "declaration of" "" { target *-*-* } 1190 } diff --git a/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc b/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc index ca91e46c84d..6a611e833c6 100644 --- a/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc +++ b/libstdc++-v3/testsuite/20_util/ratio/cons/cons_overflow_neg.cc @@ -51,4 +51,4 @@ test04() // { dg-error "instantiated from here" "" { target *-*-* } 46 } // { dg-error "denominator cannot be zero" "" { target *-*-* } 155 } // { dg-error "out of range" "" { target *-*-* } 156 } -// { dg-error "overflow in constant expression" "" { target *-*-* } 74 } +// { dg-error "overflow in constant expression" "" { target *-*-* } 99 } diff --git a/libstdc++-v3/testsuite/util/testsuite_tr1.h b/libstdc++-v3/testsuite/util/testsuite_tr1.h index 6a48a309e18..7e36ee3f5fe 100644 --- a/libstdc++-v3/testsuite/util/testsuite_tr1.h +++ b/libstdc++-v3/testsuite/util/testsuite_tr1.h @@ -1,7 +1,7 @@ // -*- C++ -*- // Testing utilities for the tr1 testsuite. // -// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010 +// Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2011 // Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free @@ -283,6 +283,130 @@ namespace __gnu_test check_ret_type(T) { return true; } +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + namespace construct_destruct + { + struct Empty {}; + + struct B { int i; B(){} }; + struct D : B {}; + + enum E { ee1 }; + enum E2 { ee2 }; + enum class SE { e1 }; + enum class SE2 { e2 }; + + enum OpE : int; + enum class OpSE : bool; + + union U { int i; Empty b; }; + + struct Abstract + { + virtual ~Abstract() = 0; + }; + + struct AbstractDelDtor + { + ~AbstractDelDtor() = delete; + virtual void foo() = 0; + }; + + struct Ukn; + + template + struct ImplicitTo + { + operator To(); + }; + + template + struct DelImplicitTo + { + operator To() = delete; + }; + + template + struct ExplicitTo + { + explicit operator To(); + }; + + struct Ellipsis + { + Ellipsis(...){} + }; + + struct DelEllipsis + { + DelEllipsis(...) = delete; + }; + + struct Any + { + template + Any(T&&){} + }; + + struct nAny + { + template + nAny(T&&...){} + }; + + struct DelnAny + { + template + DelnAny(T&&...) = delete; + }; + + template + struct FromArgs + { + FromArgs(Args...); + }; + + struct DelDef + { + DelDef() = delete; + }; + + struct DelCopy + { + DelCopy(const DelCopy&) = delete; + }; + + struct DelDtor + { + DelDtor() = default; + DelDtor(const DelDtor&) = default; + DelDtor(DelDtor&&) = default; + DelDtor(int); + DelDtor(int, B, U); + ~DelDtor() = delete; + }; + + struct Nontrivial + { + Nontrivial(); + Nontrivial(const Nontrivial&); + Nontrivial& operator=(const Nontrivial&); + ~Nontrivial(); + }; + + union NontrivialUnion + { + int i; + Nontrivial n; + }; + + struct UnusualCopy + { + UnusualCopy(UnusualCopy&); + }; + } +#endif + } // namespace __gnu_test #endif // _GLIBCXX_TESTSUITE_TR1_H -- 2.30.2