From 7b50cdeffbd3fcb4029eee0c0d85f4ea19fcc47f Mon Sep 17 00:00:00 2001 From: Benjamin Kosnik Date: Thu, 3 May 2007 11:49:12 +0000 Subject: [PATCH] type_traits (enable_if): New. 2007-05-03 Benjamin Kosnik * include/std/type_traits (enable_if): New. (conditional): New. (__decay_selector, decay): New. (__cv_selector, __match_cv_qualifiers): New. (__make_unsigned, __make_unsigned_selector, make_unsigned): New. (__make_signed, __make_signed_selector, make_signed): New. (has_trivial_constructor): ... to has_trivial_default_constructor. (has_nothrow_constructor): ... to has_nothrow_default_constructor. (has_trivial_copy): ... to has_trivial_copy_constructor. (has_nothrow_copy): ... to has_nothrow_copy_constructor. * include/tr1/type_traits_fwd: Move to... * include/tr1/type_traitsfwd: ... this, consistency with ios/string/locale forward headers. * include/tr1/type_traits: Adjust include. * include/Makefile.am (tr1_headers): Change type_traits_fwd.h to type_traitsfwd.h. * include/Makefile.in: Regenerate. * testsuite/23_containers/tuple: Move... * testsuite/20_util/tuple:... here. * testsuite/20_util/conditional: New. * testsuite/20_util/conditional/requirements: Same. * testsuite/20_util/conditional/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/conditional/requirements/typedefs.cc: Same. * testsuite/20_util/decay: Same. * testsuite/20_util/decay/requirements: Same. * testsuite/20_util/decay/requirements/explicit_instantiation.cc: Same. * testsuite/20_util/decay/requirements/typedefs.cc: Same. * testsuite/20_util/enable_if: Same. * testsuite/20_util/enable_if/requirements: Same. * testsuite/20_util/enable_if/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/enable_if/requirements/typedefs.cc: Same. * testsuite/20_util/enable_if/requirements/typedefs_neg.cc: Same. * testsuite/20_util/has_nothrow_copy_constructor: Same. * testsuite/20_util/has_nothrow_copy_constructor/requirements: Same. * testsuite/20_util/has_nothrow_copy_constructor/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/has_nothrow_copy_constructor/requirements/ typedefs.cc: Same. * testsuite/20_util/has_nothrow_copy_constructor/value.cc: Same. * testsuite/20_util/has_nothrow_default_constructor: Same. * testsuite/20_util/has_nothrow_default_constructor/requirements: Same. * testsuite/20_util/has_nothrow_default_constructor/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/has_nothrow_default_constructor/requirements/ typedefs.cc: Same. * testsuite/20_util/has_nothrow_default_constructor/value.cc: Same. * testsuite/20_util/has_trivial_copy_constructor: Same. * testsuite/20_util/has_trivial_copy_constructor/requirements: Same. * testsuite/20_util/has_trivial_copy_constructor/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/has_trivial_copy_constructor/requirements/ typedefs.cc: Same. * testsuite/20_util/has_trivial_copy_constructor/value.cc: Same. * testsuite/20_util/has_trivial_default_constructor: Same. * testsuite/20_util/has_trivial_default_constructor/requirements: Same. * testsuite/20_util/has_trivial_default_constructor/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/has_trivial_default_constructor/requirements/ typedefs.cc: Same. * testsuite/20_util/has_trivial_default_constructor/value.cc: Same. * testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc: Same. * testsuite/20_util/make_signed: Same. * testsuite/20_util/make_signed/requirements: Same. * testsuite/20_util/make_signed/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/make_signed/requirements/typedefs.cc: Same. * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same. * testsuite/20_util/make_unsigned: Same. * testsuite/20_util/make_unsigned/requirements: Same. * testsuite/20_util/make_unsigned/requirements/ explicit_instantiation.cc: Same. * testsuite/20_util/make_unsigned/requirements/typedefs.cc: Same. * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same. From-SVN: r124374 --- libstdc++-v3/ChangeLog | 81 +++++ libstdc++-v3/include/Makefile.am | 2 +- libstdc++-v3/include/Makefile.in | 2 +- libstdc++-v3/include/std/type_traits | 300 ++++++++++++++++++ libstdc++-v3/include/tr1/type_traits | 2 +- .../{type_traits_fwd.h => type_traitsfwd.h} | 6 +- .../requirements/explicit_instantiation.cc | 41 +++ .../conditional/requirements/typedefs.cc | 42 +++ .../requirements/explicit_instantiation.cc | 41 +++ .../20_util/decay/requirements/typedefs.cc | 52 +++ .../requirements/explicit_instantiation.cc | 41 +++ .../enable_if/requirements/typedefs.cc | 33 ++ .../enable_if/requirements/typedefs_neg.cc | 36 +++ .../requirements/explicit_instantiation.cc | 40 +++ .../requirements/typedefs.cc | 37 +++ .../has_nothrow_copy_constructor/value.cc | 54 ++++ .../requirements/explicit_instantiation.cc | 40 +++ .../requirements/typedefs.cc | 37 +++ .../has_nothrow_default_constructor/value.cc | 59 ++++ .../requirements/explicit_instantiation.cc | 40 +++ .../requirements/typedefs.cc | 37 +++ .../has_trivial_copy_constructor/value.cc | 56 ++++ .../requirements/explicit_instantiation.cc | 40 +++ .../requirements/typedefs.cc | 37 +++ .../has_trivial_default_constructor/value.cc | 59 ++++ .../type_traits/types_std_c++0x_neg.cc | 37 +++ .../requirements/explicit_instantiation.cc | 40 +++ .../make_signed/requirements/typedefs.cc | 68 ++++ .../make_signed/requirements/typedefs_neg.cc | 53 ++++ .../requirements/explicit_instantiation.cc | 40 +++ .../make_unsigned/requirements/typedefs.cc | 68 ++++ .../requirements/typedefs_neg.cc | 53 ++++ .../requirements/explicit_instantiation.cc | 0 33 files changed, 1568 insertions(+), 6 deletions(-) rename libstdc++-v3/include/tr1/{type_traits_fwd.h => type_traitsfwd.h} (98%) create mode 100644 libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc create mode 100644 libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc create mode 100644 libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc rename libstdc++-v3/testsuite/{23_containers => 20_util}/tuple/requirements/explicit_instantiation.cc (100%) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 1aee8b0baf8..48a0494cb5b 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,84 @@ +2007-05-03 Benjamin Kosnik + + * include/std/type_traits (enable_if): New. + (conditional): New. + (__decay_selector, decay): New. + (__cv_selector, __match_cv_qualifiers): New. + (__make_unsigned, __make_unsigned_selector, make_unsigned): New. + (__make_signed, __make_signed_selector, make_signed): New. + (has_trivial_constructor): ... to has_trivial_default_constructor. + (has_nothrow_constructor): ... to has_nothrow_default_constructor. + (has_trivial_copy): ... to has_trivial_copy_constructor. + (has_nothrow_copy): ... to has_nothrow_copy_constructor. + + * include/tr1/type_traits_fwd: Move to... + * include/tr1/type_traitsfwd: ... this, consistency with + ios/string/locale forward headers. + * include/tr1/type_traits: Adjust include. + * include/Makefile.am (tr1_headers): Change type_traits_fwd.h to + type_traitsfwd.h. + * include/Makefile.in: Regenerate. + + * testsuite/23_containers/tuple: Move... + * testsuite/20_util/tuple:... here. + + * testsuite/20_util/conditional: New. + * testsuite/20_util/conditional/requirements: Same. + * testsuite/20_util/conditional/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/conditional/requirements/typedefs.cc: Same. + * testsuite/20_util/decay: Same. + * testsuite/20_util/decay/requirements: Same. + * testsuite/20_util/decay/requirements/explicit_instantiation.cc: Same. + * testsuite/20_util/decay/requirements/typedefs.cc: Same. + * testsuite/20_util/enable_if: Same. + * testsuite/20_util/enable_if/requirements: Same. + * testsuite/20_util/enable_if/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/enable_if/requirements/typedefs.cc: Same. + * testsuite/20_util/enable_if/requirements/typedefs_neg.cc: Same. + * testsuite/20_util/has_nothrow_copy_constructor: Same. + * testsuite/20_util/has_nothrow_copy_constructor/requirements: Same. + * testsuite/20_util/has_nothrow_copy_constructor/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/has_nothrow_copy_constructor/requirements/ + typedefs.cc: Same. + * testsuite/20_util/has_nothrow_copy_constructor/value.cc: Same. + * testsuite/20_util/has_nothrow_default_constructor: Same. + * testsuite/20_util/has_nothrow_default_constructor/requirements: Same. + * testsuite/20_util/has_nothrow_default_constructor/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/has_nothrow_default_constructor/requirements/ + typedefs.cc: Same. + * testsuite/20_util/has_nothrow_default_constructor/value.cc: Same. + * testsuite/20_util/has_trivial_copy_constructor: Same. + * testsuite/20_util/has_trivial_copy_constructor/requirements: Same. + * testsuite/20_util/has_trivial_copy_constructor/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/has_trivial_copy_constructor/requirements/ + typedefs.cc: Same. + * testsuite/20_util/has_trivial_copy_constructor/value.cc: Same. + * testsuite/20_util/has_trivial_default_constructor: Same. + * testsuite/20_util/has_trivial_default_constructor/requirements: Same. + * testsuite/20_util/has_trivial_default_constructor/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/has_trivial_default_constructor/requirements/ + typedefs.cc: Same. + * testsuite/20_util/has_trivial_default_constructor/value.cc: Same. + * testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc: Same. + * testsuite/20_util/make_signed: Same. + * testsuite/20_util/make_signed/requirements: Same. + * testsuite/20_util/make_signed/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/make_signed/requirements/typedefs.cc: Same. + * testsuite/20_util/make_signed/requirements/typedefs_neg.cc: Same. + * testsuite/20_util/make_unsigned: Same. + * testsuite/20_util/make_unsigned/requirements: Same. + * testsuite/20_util/make_unsigned/requirements/ + explicit_instantiation.cc: Same. + * testsuite/20_util/make_unsigned/requirements/typedefs.cc: Same. + * testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc: Same. + 2007-05-02 Paolo Carlini PR libstdc++/31777 diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 75be19a5f78..ea27464432e 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -592,7 +592,7 @@ tr1_headers = \ ${tr1_srcdir}/tgmath.h \ ${tr1_srcdir}/tuple \ ${tr1_srcdir}/type_traits \ - ${tr1_srcdir}/type_traits_fwd.h \ + ${tr1_srcdir}/type_traitsfwd.h \ ${tr1_srcdir}/unordered_set \ ${tr1_srcdir}/unordered_map \ ${tr1_srcdir}/utility \ diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 5b4ad599218..4402d84c67f 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -822,7 +822,7 @@ tr1_headers = \ ${tr1_srcdir}/tgmath.h \ ${tr1_srcdir}/tuple \ ${tr1_srcdir}/type_traits \ - ${tr1_srcdir}/type_traits_fwd.h \ + ${tr1_srcdir}/type_traitsfwd.h \ ${tr1_srcdir}/unordered_set \ ${tr1_srcdir}/unordered_map \ ${tr1_srcdir}/utility \ diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 1d83dabd861..0d7e85e5300 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -42,5 +42,305 @@ # include #endif +_GLIBCXX_BEGIN_NAMESPACE(std) + + // Define a nested type if some predicate holds. + template + struct enable_if + { }; + + template + struct enable_if + { typedef _Tp type; }; + + + // Like a conditional expression, but for types. If true, first, if + // false, second. + template + struct conditional + { typedef _Iftrue type; }; + + template + struct conditional + { typedef _Iffalse 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 __decay_selector<_Up, false, false> + { typedef _Up __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; }; + + template + struct decay + { + private: + typedef typename remove_reference<_Tp>::type __remove_type; + + public: + typedef typename __decay_selector<__remove_type>::__type type; + }; + + + // Utility for constructing identically cv-qualified types. + template + struct __cv_selector; + + template + struct __cv_selector<_Unqualified, false, false> + { typedef _Unqualified __type; }; + + template + struct __cv_selector<_Unqualified, false, true> + { typedef volatile _Unqualified __type; }; + + template + struct __cv_selector<_Unqualified, true, false> + { typedef const _Unqualified __type; }; + + template + struct __cv_selector<_Unqualified, true, true> + { typedef const volatile _Unqualified __type; }; + + template::value, + bool _IsVol = is_volatile<_Qualified>::value> + struct __match_cv_qualifiers + { + private: + typedef __cv_selector<_Unqualified, _IsConst, _IsVol> __match; + + public: + typedef typename __match::__type __type; + }; + + + // Utility for finding the unsigned versions of signed integral types. + template + struct __make_unsigned; + + template<> + struct __make_unsigned + { typedef unsigned char __type; }; + + template<> + struct __make_unsigned + { typedef unsigned char __type; }; + + template<> + struct __make_unsigned + { typedef unsigned wchar_t __type; }; + + template<> + struct __make_unsigned + { typedef unsigned short __type; }; + + template<> + struct __make_unsigned + { typedef unsigned int __type; }; + + template<> + struct __make_unsigned + { typedef unsigned long __type; }; + + template<> + struct __make_unsigned + { typedef unsigned long long __type; }; + + + // Select between integral and enum: not possible to be both. + template::value, + bool _IsUnsigned = is_unsigned<_Tp>::value, + bool _IsEnum = is_enum<_Tp>::value> + struct __make_unsigned_selector; + + template + struct __make_unsigned_selector<_Tp, true, true, false> + { typedef _Tp __type; }; + + template + struct __make_unsigned_selector<_Tp, true, false, false> + { + private: + typedef __make_unsigned::type> __unsignedt; + typedef typename __unsignedt::__type __unsigned_type; + typedef __match_cv_qualifiers<_Tp, __unsigned_type> __cv_unsigned; + + public: + typedef typename __cv_unsigned::__type __type; + }; + + template + struct __make_unsigned_selector<_Tp, false, true, false> + { + private: + // GNU floating point types start with sizeof int. + static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned int); + static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned long); + typedef conditional<__b2, unsigned long, unsigned long long> __cond; + typedef typename __cond::type __cond_type; + typedef unsigned int __ui_type; + + public: + typedef typename conditional<__b1, __ui_type, __cond_type>::type __type; + }; + + template + struct __make_unsigned_selector<_Tp, false, false, true> + { + private: + // GNU enums start with sizeof int. + static const bool __b1 = sizeof(_Tp) <= sizeof(unsigned int); + static const bool __b2 = sizeof(_Tp) <= sizeof(unsigned long); + typedef conditional<__b2, unsigned long, unsigned long long> __cond; + typedef typename __cond::type __cond_type; + typedef unsigned int __ui_type; + + public: + typedef typename conditional<__b1, __ui_type, __cond_type>::type __type; + }; + + // Primary class template. + // Given an integral/enum type, return the corresponding unsigned + // integer type. + template + struct make_unsigned + { typedef typename __make_unsigned_selector<_Tp>::__type type; }; + + // Integral, but don't define. + template<> + struct make_unsigned; + + + // Utility for finding the signed versions of unsigned integral types. + template + struct __make_signed; + + template<> + struct __make_signed + { typedef signed char __type; }; + + template<> + struct __make_signed + { typedef signed char __type; }; + + template<> + struct __make_signed + { typedef signed wchar_t __type; }; + + template<> + struct __make_signed + { typedef signed short __type; }; + + template<> + struct __make_signed + { typedef signed int __type; }; + + template<> + struct __make_signed + { typedef signed long __type; }; + + template<> + struct __make_signed + { typedef signed long long __type; }; + + + // Select between arithmetic and enum: not possible to be both. + template::value, + bool _IsSigned = is_signed<_Tp>::value, + bool _IsEnum = is_enum<_Tp>::value> + struct __make_signed_selector; + + template + struct __make_signed_selector<_Tp, true, true, false> + { typedef _Tp __type; }; + + template + struct __make_signed_selector<_Tp, true, false, false> + { + private: + typedef __make_signed::type> __signedt; + typedef typename __signedt::__type __signed_type; + typedef __match_cv_qualifiers<_Tp, __signed_type> __cv_signed; + + public: + typedef typename __cv_signed::__type __type; + }; + + template + struct __make_signed_selector<_Tp, false, true, false> + { + // GNU floating point types start with sizeof int. + static const bool __b1 = sizeof(_Tp) <= sizeof(signed int); + static const bool __b2 = sizeof(_Tp) <= sizeof(signed long); + typedef conditional<__b2, signed long, signed long long> __cond; + typedef typename __cond::type __cond_type; + typedef unsigned int __i_type; + + public: + typedef typename conditional<__b1, __i_type, __cond_type>::type __type; + }; + + template + struct __make_signed_selector<_Tp, false, false, true> + { + private: + // GNU enums start with sizeof int. + static const bool __b1 = sizeof(_Tp) <= sizeof(signed int); + static const bool __b2 = sizeof(_Tp) <= sizeof(signed long); + typedef conditional<__b2, signed long, signed long long> __cond; + typedef typename __cond::type __cond_type; + typedef int __i_type; + + public: + typedef typename conditional<__b1, __i_type, __cond_type>::type __type; + }; + + // Primary class template. + // Given an integral/enum type, return the corresponding signed + // integer type. + template + struct make_signed + { typedef typename __make_signed_selector<_Tp>::__type type; }; + + // Integral, but don't define. + template<> + struct make_signed; + + + template + struct has_nothrow_default_constructor + : public integral_constant::value> { }; + + template + struct has_nothrow_copy_constructor + : public integral_constant::value> { }; + + template + struct has_trivial_default_constructor + : public integral_constant::value> { }; + + template + struct has_trivial_copy_constructor + : public integral_constant::value> { }; + +_GLIBCXX_END_NAMESPACE + #endif diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits index c824ef77a31..41edc3adbc0 100644 --- a/libstdc++-v3/include/tr1/type_traits +++ b/libstdc++-v3/include/tr1/type_traits @@ -37,7 +37,7 @@ #pragma GCC system_header #include -#include +#include // namespace std::tr1 namespace std diff --git a/libstdc++-v3/include/tr1/type_traits_fwd.h b/libstdc++-v3/include/tr1/type_traitsfwd.h similarity index 98% rename from libstdc++-v3/include/tr1/type_traits_fwd.h rename to libstdc++-v3/include/tr1/type_traitsfwd.h index c6e80a3a4b9..497801447b1 100644 --- a/libstdc++-v3/include/tr1/type_traits_fwd.h +++ b/libstdc++-v3/include/tr1/type_traitsfwd.h @@ -27,13 +27,13 @@ // invalidate any other reasons why the executable file might be covered by // the GNU General Public License. -/** @file tr1/type_traits_fwd.h +/** @file tr1/type_traitsfwd.h * This is an internal header file, included by other library headers. * You should not attempt to use it directly. */ -#ifndef _TYPE_TRAITS_FWD_H -#define _TYPE_TRAITS_FWD_H 1 +#ifndef _TYPE_TRAITSFWD_H +#define _TYPE_TRAIT_FWD_H 1 #include diff --git a/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..079d366590e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/conditional/requirements/explicit_instantiation.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct conditional; +} diff --git a/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc new file mode 100644 index 00000000000..980cd6dd986 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/conditional/requirements/typedefs.cc @@ -0,0 +1,42 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::conditional; + + typedef conditional::type test1_type; + VERIFY( (std::is_same::value) ); + + typedef conditional::type test2_type; + VERIFY( (std::is_same::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..d804d11ffb8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/decay/requirements/explicit_instantiation.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct decay; +} diff --git a/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc new file mode 100644 index 00000000000..162ddd2ff42 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/decay/requirements/typedefs.cc @@ -0,0 +1,52 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::decay; + using std::is_same; + + // Positive tests. + typedef decay::type test1_type; + VERIFY( (is_same::value) ); + + typedef decay::type test2_type; + VERIFY( (is_same::value) ); + + typedef decay::type test3_type; + VERIFY( (is_same::type*>::value) ); + + typedef void (fn_type) (); + typedef decay::type test4_type; + VERIFY( (is_same::type>::value) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..f236eabadfc --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/explicit_instantiation.cc @@ -0,0 +1,41 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// 2007-05-02 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct enable_if; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc new file mode 100644 index 00000000000..34deb210354 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs.cc @@ -0,0 +1,33 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Positive tests. + typedef enable_if::type test1_type; +} diff --git a/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc new file mode 100644 index 00000000000..daff6ad3fb4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/enable_if/requirements/typedefs_neg.cc @@ -0,0 +1,36 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-02 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::enable_if; + + // Negative tests. + typedef enable_if::type test2_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 33 } diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..dff484e9d6e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_nothrow_copy_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc new file mode 100644 index 00000000000..02c30d9f3aa --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_nothrow_copy_constructor 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/has_nothrow_copy_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc new file mode 100644 index 00000000000..ac793178ac5 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_copy_constructor/value.cc @@ -0,0 +1,54 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_nothrow_copy_constructor; + 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)) ); + 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)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..e56d7090bf8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_nothrow_default_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc new file mode 100644 index 00000000000..6eeb6f06501 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-29 Paolo Carlini +// +// Copyright (C) 2004, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_nothrow_default_constructor 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/has_nothrow_default_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc new file mode 100644 index 00000000000..fccbcf74d28 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_nothrow_default_constructor/value.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-29 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2006, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_nothrow_default_constructor; + 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)) ); + 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)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..a6bb87dc7c3 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_trivial_copy_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc new file mode 100644 index 00000000000..7b49ff3ed2e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_copy_constructor 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/has_trivial_copy_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc new file mode 100644 index 00000000000..2ea418a2e9c --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_copy_constructor/value.cc @@ -0,0 +1,56 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-30 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_trivial_copy_constructor; + 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)) ); + 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)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..03b3050495e --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct has_trivial_default_constructor; +} diff --git a/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc new file mode 100644 index 00000000000..af8e7265532 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/requirements/typedefs.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-26 Paolo Carlini +// +// Copyright (C) 2004, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::has_trivial_default_constructor 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/has_trivial_default_constructor/value.cc b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc new file mode 100644 index 00000000000..fae5ace9f76 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/has_trivial_default_constructor/value.cc @@ -0,0 +1,59 @@ +// { dg-options "-std=gnu++0x" } +// 2004-12-26 Paolo Carlini +// +// Copyright (C) 2004, 2005, 2006, 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// 4.5.3 Type properties + +#include +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::has_trivial_default_constructor; + 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)) ); + 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)) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc new file mode 100644 index 00000000000..37c5a0346d1 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/headers/type_traits/types_std_c++0x_neg.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include + +namespace gnu +{ + // C++0x changes from TR1. + using std::has_trivial_constructor; + using std::has_nothrow_constructor; + using std::has_trivial_copy; + using std::has_nothrow_copy; +} + +// { dg-error "has not been declared" "" { target *-*-* } 27 } +// { dg-error "has not been declared" "" { target *-*-* } 28 } +// { dg-error "has not been declared" "" { target *-*-* } 29 } +// { dg-error "has not been declared" "" { target *-*-* } 30 } + diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..ca0ed884051 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct make_signed; +} diff --git a/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc new file mode 100644 index 00000000000..826e47ed3e8 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_signed; + using std::is_same; + + // Positive tests. + typedef make_signed::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test22_type; + VERIFY( (is_same::value) ); + + typedef make_signed::type test23_type; + VERIFY( (is_same::value) ); + +#if 0 + // XXX + // When is_signed works for floating points types this should pass + typedef make_signed::type test24_type; + VERIFY( (is_same::value) ); +#endif + + typedef make_signed::type test25_type; + VERIFY( (is_same::value) ); +} + +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 new file mode 100644 index 00000000000..aa94f2a4708 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_signed/requirements/typedefs_neg.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_signed; + + // Negative tests. + typedef make_signed::type test1_type; + + typedef make_signed<__gnu_test::pod_uint>::type test2_type; + + typedef make_signed::type test3_type; + + typedef void (fn_type) (); + typedef make_signed::type test4_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 34 } +// { dg-error "instantiated from here" "" { target *-*-* } 36 } +// { dg-error "instantiated from here" "" { target *-*-* } 38 } +// { dg-error "instantiated from here" "" { target *-*-* } 41 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 320 } +// { dg-error "declaration of" "" { target *-*-* } 268 } + +// { dg-excess-errors "At global scope" } +// { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc new file mode 100644 index 00000000000..bc836a7d64a --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/explicit_instantiation.cc @@ -0,0 +1,40 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// 2007-04-30 Benjamin Kosnik + +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +// As a special exception, you may use this file as part of a free software +// library without restriction. Specifically, if other files instantiate +// templates or use macros or inline functions from this file, or you compile +// this file and link it with other files to produce an executable, this +// file does not by itself cause the resulting executable to be covered by +// the GNU General Public License. This exception does not however +// invalidate any other reasons why the executable file might be covered by +// the GNU General Public License. + +// NB: This file is for testing type_traits with NO OTHER INCLUDES. + +#include + +namespace std +{ + typedef short test_type; + template struct make_unsigned; +} diff --git a/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc new file mode 100644 index 00000000000..b09d3e93aa4 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs.cc @@ -0,0 +1,68 @@ +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::make_unsigned; + using std::is_same; + + // Positive tests. + typedef make_unsigned::type test2_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21c_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21v_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test21cv_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test22_type; + VERIFY( (is_same::value) ); + + typedef make_unsigned::type test23_type; + VERIFY( (is_same::value) ); + +#if 0 + // XXX + // When is_unsigned works for floating points types this should pass + typedef make_unsigned::type test24_type; + VERIFY( (is_same::value) ); +#endif + + typedef make_unsigned::type test25_type; + VERIFY( (is_same::value) ); +} + +int main() +{ + test01(); + return 0; +} 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 new file mode 100644 index 00000000000..cc07d616954 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/make_unsigned/requirements/typedefs_neg.cc @@ -0,0 +1,53 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// 2007-05-03 Benjamin Kosnik +// +// Copyright (C) 2007 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 2, 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 COPYING. If not, write to the Free +// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +// USA. + +#include +#include + +enum test_enum { first_selection }; + +void test01() +{ + using std::make_unsigned; + + // Negative tests. + typedef make_unsigned::type test1_type; + + typedef make_unsigned<__gnu_test::pod_uint>::type test2_type; + + typedef make_unsigned::type test3_type; + + typedef void (fn_type) (); + typedef make_unsigned::type test4_type; +} + +// { dg-error "does not name a type" "" { target *-*-* } 34 } +// { dg-error "instantiated from here" "" { target *-*-* } 36 } +// { dg-error "instantiated from here" "" { target *-*-* } 38 } +// { dg-error "instantiated from here" "" { target *-*-* } 41 } + +// { dg-error "invalid use of incomplete type" "" { target *-*-* } 223 } +// { dg-error "declaration of" "" { target *-*-* } 170 } + +// { dg-excess-errors "At global scope" } +// { dg-excess-errors "In instantiation of" } diff --git a/libstdc++-v3/testsuite/23_containers/tuple/requirements/explicit_instantiation.cc b/libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc similarity index 100% rename from libstdc++-v3/testsuite/23_containers/tuple/requirements/explicit_instantiation.cc rename to libstdc++-v3/testsuite/20_util/tuple/requirements/explicit_instantiation.cc -- 2.30.2