From 493bc46004681c9ab631a38fc62f086f6274aaea Mon Sep 17 00:00:00 2001 From: Paolo Carlini Date: Sat, 4 Dec 2004 09:08:42 +0000 Subject: [PATCH] type_traits: New. 2004-12-04 Paolo Carlini * include/tr1/type_traits: New. * include/Makefile.am: Add. * include/Makefile.in: Regenerate. * testsuite/testsuite_tr1.h: New. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_arithmetic/is_arithmetic.cc: New. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_arithmetic/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_fundamental/is_fundamental.cc: Likewise. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_fundamental/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/helper_classes/ true_false_type.cc: Likewise. * testsuite/tr1/4_metaprogramming/helper_classes/ true_false_type_typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/helper_classes/ typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_array/is_array.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_array/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_floating_point/is_floating_point.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_floating_point/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_integral/is_integral.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_integral/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_void/is_void.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_void/typedefs.cc: Likewise. From-SVN: r91723 --- libstdc++-v3/ChangeLog | 37 +++ libstdc++-v3/include/Makefile.am | 3 +- libstdc++-v3/include/Makefile.in | 3 +- libstdc++-v3/include/tr1/type_traits | 283 ++++++++++++++++++ libstdc++-v3/testsuite/testsuite_tr1.h | 55 ++++ .../is_arithmetic/is_arithmetic.cc | 63 ++++ .../is_arithmetic/typedefs.cc | 36 +++ .../is_fundamental/is_fundamental.cc | 62 ++++ .../is_fundamental/typedefs.cc | 36 +++ .../helper_classes/true_false_type.cc | 42 +++ .../true_false_type_typedefs.cc | 43 +++ .../helper_classes/typedefs.cc | 36 +++ .../is_array/is_array.cc | 57 ++++ .../is_array/typedefs.cc | 36 +++ .../is_floating_point/is_floating_point.cc | 63 ++++ .../is_floating_point/typedefs.cc | 36 +++ .../is_integral/is_integral.cc | 64 ++++ .../is_integral/typedefs.cc | 36 +++ .../is_void/is_void.cc | 63 ++++ .../is_void/typedefs.cc | 36 +++ 20 files changed, 1088 insertions(+), 2 deletions(-) create mode 100644 libstdc++-v3/include/tr1/type_traits create mode 100644 libstdc++-v3/testsuite/testsuite_tr1.h create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/is_arithmetic.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/typedefs.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/is_fundamental.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/typedefs.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/true_false_type.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/true_false_type_typedefs.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/typedefs.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/is_array.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/typedefs.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/is_floating_point.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/typedefs.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/is_integral.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/typedefs.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/is_void.cc create mode 100644 libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/typedefs.cc diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 5ea2e14087c..73568bdb042 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,40 @@ +2004-12-04 Paolo Carlini + + * include/tr1/type_traits: New. + * include/Makefile.am: Add. + * include/Makefile.in: Regenerate. + * testsuite/testsuite_tr1.h: New. + * testsuite/tr1/4_metaprogramming/composite_type_traits/ + is_arithmetic/is_arithmetic.cc: New. + * testsuite/tr1/4_metaprogramming/composite_type_traits/ + is_arithmetic/typedefs.cc: Likewise. + * testsuite/tr1/4_metaprogramming/composite_type_traits/ + is_fundamental/is_fundamental.cc: Likewise. + * testsuite/tr1/4_metaprogramming/composite_type_traits/ + is_fundamental/typedefs.cc: Likewise. + * testsuite/tr1/4_metaprogramming/helper_classes/ + true_false_type.cc: Likewise. + * testsuite/tr1/4_metaprogramming/helper_classes/ + true_false_type_typedefs.cc: Likewise. + * testsuite/tr1/4_metaprogramming/helper_classes/ + typedefs.cc: Likewise. + * testsuite/tr1/4_metaprogramming/primary_type_categories/ + is_array/is_array.cc: Likewise. + * testsuite/tr1/4_metaprogramming/primary_type_categories/ + is_array/typedefs.cc: Likewise. + * testsuite/tr1/4_metaprogramming/primary_type_categories/ + is_floating_point/is_floating_point.cc: Likewise. + * testsuite/tr1/4_metaprogramming/primary_type_categories/ + is_floating_point/typedefs.cc: Likewise. + * testsuite/tr1/4_metaprogramming/primary_type_categories/ + is_integral/is_integral.cc: Likewise. + * testsuite/tr1/4_metaprogramming/primary_type_categories/ + is_integral/typedefs.cc: Likewise. + * testsuite/tr1/4_metaprogramming/primary_type_categories/ + is_void/is_void.cc: Likewise. + * testsuite/tr1/4_metaprogramming/primary_type_categories/ + is_void/typedefs.cc: Likewise. + 2004-12-02 Paolo Carlini * testsuite/testsuite_io.h (class sync_buf): New, templatized diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am index 2bcc65d5927..dcfa0e05f98 100644 --- a/libstdc++-v3/include/Makefile.am +++ b/libstdc++-v3/include/Makefile.am @@ -231,7 +231,8 @@ tr1_headers = \ ${tr1_srcdir}/array \ ${tr1_srcdir}/functional \ ${tr1_srcdir}/tuple \ - ${tr1_srcdir}/utility + ${tr1_srcdir}/utility \ + ${tr1_srcdir}/type_traits # This is the common subset of files that all three "C" header models use. diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in index 4f8cd9a9892..44723bef1d5 100644 --- a/libstdc++-v3/include/Makefile.in +++ b/libstdc++-v3/include/Makefile.in @@ -448,7 +448,8 @@ tr1_headers = \ ${tr1_srcdir}/array \ ${tr1_srcdir}/functional \ ${tr1_srcdir}/tuple \ - ${tr1_srcdir}/utility + ${tr1_srcdir}/utility \ + ${tr1_srcdir}/type_traits # This is the common subset of files that all three "C" header models use. diff --git a/libstdc++-v3/include/tr1/type_traits b/libstdc++-v3/include/tr1/type_traits new file mode 100644 index 00000000000..913a2b71c81 --- /dev/null +++ b/libstdc++-v3/include/tr1/type_traits @@ -0,0 +1,283 @@ +// TR1 type_traits -*- C++ -*- + +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +/** @file + * This is a TR1 C++ Library header. + */ + +#ifndef _TR1_TYPE_TRAITS +#define _TR1_TYPE_TRAITS 1 + +#include +#include + +//namespace std::tr1 +namespace std +{ +namespace tr1 +{ + /// @brief helper classes [4.3]. + template + struct integral_constant + { + static const _Tp value = __v; + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; + }; + typedef integral_constant true_type; + typedef integral_constant false_type; + +#define _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type) \ + template<> \ + struct _Primary<_Type> \ + : public true_type { }; + +#define _DEFINE_PRIMARY_SPEC(_Primary, _Type) \ + _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type) \ + _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type const) \ + _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type volatile) \ + _DEFINE_PRIMARY_SPEC_HELPER(_Primary, _Type const volatile) + + /// @brief primary type categories [4.5.1]. + template + struct is_void + : public false_type { }; + _DEFINE_PRIMARY_SPEC(is_void, void) + + template + struct is_integral + : public false_type { }; + _DEFINE_PRIMARY_SPEC(is_integral, bool) + _DEFINE_PRIMARY_SPEC(is_integral, char) + _DEFINE_PRIMARY_SPEC(is_integral, signed char) + _DEFINE_PRIMARY_SPEC(is_integral, unsigned char) +#ifdef _GLIBCXX_USE_WCHAR_T + _DEFINE_PRIMARY_SPEC(is_integral, wchar_t) +#endif + _DEFINE_PRIMARY_SPEC(is_integral, short) + _DEFINE_PRIMARY_SPEC(is_integral, unsigned short) + _DEFINE_PRIMARY_SPEC(is_integral, int) + _DEFINE_PRIMARY_SPEC(is_integral, unsigned int) + _DEFINE_PRIMARY_SPEC(is_integral, long) + _DEFINE_PRIMARY_SPEC(is_integral, unsigned long) + _DEFINE_PRIMARY_SPEC(is_integral, long long) + _DEFINE_PRIMARY_SPEC(is_integral, unsigned long long) + + template + struct is_floating_point + : public false_type { }; + _DEFINE_PRIMARY_SPEC(is_floating_point, float) + _DEFINE_PRIMARY_SPEC(is_floating_point, double) + _DEFINE_PRIMARY_SPEC(is_floating_point, long double) + + template + struct is_array + : public false_type { }; + + template + struct is_array<_Tp[_Size]> + : public true_type { }; + + template + struct is_array<_Tp[]> + : public true_type { }; + + template + struct is_pointer; + + template + struct is_reference; + + template + struct is_member_object_pointer; + + template + struct is_member_function_pointer; + + template + struct is_enum; + + template + struct is_union; + + template + struct is_class; + + template + struct is_function; + +#undef _DEFINE_PRIMARY_SPEC_HELPER +#undef _DEFINE_PRIMARY_SPEC + + /// @brief composite type traits [4.5.2]. + template + struct is_arithmetic + : public integral_constant::value + || is_floating_point<_Tp>::value)> + { }; + + template + struct is_fundamental + : public integral_constant::value + || is_void<_Tp>::value)> + { }; + + template + struct is_object + : public integral_constant::value + || is_reference<_Tp>::value + || is_void<_Tp>::value)> + { }; + + template + struct is_member_pointer + : public integral_constant::value + || is_member_function_pointer<_Tp>::value)> + { }; + + template + struct is_scalar + : public integral_constant::value + || is_enum<_Tp>::value + || is_pointer<_Tp>::value + || is_member_pointer<_Tp>::value)> + { }; + + template + struct is_compound + : public integral_constant::value> { }; + + /// @brief type properties [4.5.3]. + template + struct is_const; + + template + struct is_volatile; + + template + struct is_pod; + + template + struct is_empty; + + template + struct is_polymorphic; + + template + struct is_abstract; + + template + struct has_trivial_constructor; + + template + struct has_trivial_copy; + + template + struct has_trivial_assign; + + template + struct has_trivial_destructor; + + template + struct has_nothrow_constructor; + + template + struct has_nothrow_copy; + + template + struct has_nothrow_assign; + + template + struct has_virtual_destructor + : public false_type { }; + + template + struct is_signed; + + template + struct is_unsigned; + + template + struct alignment_of; + + template + struct rank; + + template + struct extent; + + /// @brief relationships between types [4.6]. + template + struct is_same; + + template + struct is_convertible; + + template + struct is_base_of; + + /// @brief const-volatile modifications [4.7.1]. + template + struct remove_const; + + template + struct remove_volatile; + + template + struct remove_cv; + + template + struct add_const; + + template + struct add_volatile; + + template + struct add_cv; + + /// @brief reference modifications [4.7.2]. + template + struct remove_reference; + + template + struct add_reference; + + /// @brief array modififications [4.7.3]. + template + struct remove_extent; + + template + struct remove_all_extents; + + /// @brief pointer modifications [4.7.4]. + template + struct remove_pointer; + + template + struct add_pointer; + + /// @brief other transformations [4.8]. + template + struct aligned_storage; +} +} + +#endif diff --git a/libstdc++-v3/testsuite/testsuite_tr1.h b/libstdc++-v3/testsuite/testsuite_tr1.h new file mode 100644 index 00000000000..70695684024 --- /dev/null +++ b/libstdc++-v3/testsuite/testsuite_tr1.h @@ -0,0 +1,55 @@ +// -*- C++ -*- +// Testing utilities for the tr1 testsuite. +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// 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. + +#ifndef _GLIBCXX_TESTSUITE_TR1_H +#define _GLIBCXX_TESTSUITE_TR1_H + +namespace __gnu_test +{ + // For tr1/type_traits. + template class Category, + typename Type, bool Tv> + bool + test_category() + { + bool ret = true; + ret &= Category::value == Tv; + ret &= Category::value == Tv; + ret &= Category::value == Tv; + ret &= Category::value == Tv; + ret &= Category::type::value == Tv; + ret &= Category::type::value == Tv; + ret &= Category::type::value == Tv; + ret &= Category::type::value == Tv; + return ret; + } +}; // namespace __gnu_test + +#endif // _GLIBCXX_TESTSUITE_TR1_H diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/is_arithmetic.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/is_arithmetic.cc new file mode 100644 index 00000000000..f27ad75fe81 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/is_arithmetic.cc @@ -0,0 +1,63 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 4.5.2 Composite type traits + +#include +#include +#include + +class ClassType { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::tr1::is_arithmetic; + using __gnu_test::test_category; + + VERIFY( (test_category()) ); + + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category()) ); +#endif + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + + // Sanity check. + VERIFY( (test_category()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/typedefs.cc new file mode 100644 index 00000000000..c4075143113 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/typedefs.cc @@ -0,0 +1,36 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::tr1::is_arithmetic 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/tr1/4_metaprogramming/composite_type_traits/is_fundamental/is_fundamental.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/is_fundamental.cc new file mode 100644 index 00000000000..2858de469ac --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/is_fundamental.cc @@ -0,0 +1,62 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 4.5.2 Composite type traits + +#include +#include +#include + +class ClassType { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::tr1::is_fundamental; + using __gnu_test::test_category; + + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category()) ); +#endif + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + + // Sanity check. + VERIFY( (test_category()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/typedefs.cc new file mode 100644 index 00000000000..43bf14f1d59 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/typedefs.cc @@ -0,0 +1,36 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::tr1::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/tr1/4_metaprogramming/helper_classes/true_false_type.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/true_false_type.cc new file mode 100644 index 00000000000..c7c2b04874d --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/true_false_type.cc @@ -0,0 +1,42 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 4.3 Helper classes + +#include +#include + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::tr1::true_type; + using std::tr1::false_type; + + VERIFY( true_type::value == true ); + VERIFY( false_type::value == false ); + VERIFY( true_type::type::value == true ); + VERIFY( false_type::type::value == false ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/true_false_type_typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/true_false_type_typedefs.cc new file mode 100644 index 00000000000..403b39f6942 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/true_false_type_typedefs.cc @@ -0,0 +1,43 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::tr1::true_type true_type; + typedef std::tr1::false_type false_type; + + typedef true_type::value_type true_value_type; + typedef true_type::type true_type; + typedef true_type::type::value_type true_type_value_type; + typedef true_type::type::type true_type_type; + + typedef false_type::value_type false_value_type; + typedef false_type::type false_type; + typedef false_type::type::value_type false_type_value_type; + typedef false_type::type::type false_type_type; +} diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/typedefs.cc new file mode 100644 index 00000000000..dc5a75b5dee --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/helper_classes/typedefs.cc @@ -0,0 +1,36 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::tr1::integral_constant 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/tr1/4_metaprogramming/primary_type_categories/is_array/is_array.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/is_array.cc new file mode 100644 index 00000000000..66b1894a353 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/is_array.cc @@ -0,0 +1,57 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 4.5.1 Primary type categories + +#include +#include +#include + +class ClassType { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::tr1::is_array; + using __gnu_test::test_category; + + typedef int int_array[5]; + typedef int empty_int_array[]; + typedef float* pointer_array[5]; + typedef float* empty_pointer_array[]; + typedef ClassType ClassType_array[5]; + typedef ClassType empty_ClassType_array[]; + + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + + // Sanity check. + VERIFY( (test_category()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/typedefs.cc new file mode 100644 index 00000000000..b947a02e2e0 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/typedefs.cc @@ -0,0 +1,36 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::tr1::is_array 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/tr1/4_metaprogramming/primary_type_categories/is_floating_point/is_floating_point.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/is_floating_point.cc new file mode 100644 index 00000000000..deed15dbe6c --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/is_floating_point.cc @@ -0,0 +1,63 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 4.5.1 Primary type categories + +#include +#include +#include + +class ClassType { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::tr1::is_floating_point; + using __gnu_test::test_category; + + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category()) ); +#endif + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + + // Sanity check. + VERIFY( (test_category()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/typedefs.cc new file mode 100644 index 00000000000..00b351c3f00 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/typedefs.cc @@ -0,0 +1,36 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::tr1::is_floating_point 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/tr1/4_metaprogramming/primary_type_categories/is_integral/is_integral.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/is_integral.cc new file mode 100644 index 00000000000..d746edb8992 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/is_integral.cc @@ -0,0 +1,64 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 4.5.1 Primary type categories + +#include +#include +#include + +class ClassType { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::tr1::is_integral; + using __gnu_test::test_category; + + VERIFY( (test_category()) ); + + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category()) ); +#endif + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + + // Sanity check. + VERIFY( (test_category()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/typedefs.cc new file mode 100644 index 00000000000..59feb3625ef --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/typedefs.cc @@ -0,0 +1,36 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::tr1::is_integral 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/tr1/4_metaprogramming/primary_type_categories/is_void/is_void.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/is_void.cc new file mode 100644 index 00000000000..46b8629ade9 --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/is_void.cc @@ -0,0 +1,63 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// 4.5.1 Primary type categories + +#include +#include +#include + +class ClassType { }; + +void test01() +{ + bool test __attribute__((unused)) = true; + using std::tr1::is_void; + using __gnu_test::test_category; + + VERIFY( (test_category()) ); + + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); +#ifdef _GLIBCXX_USE_WCHAR_T + VERIFY( (test_category()) ); +#endif + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + VERIFY( (test_category()) ); + + // Sanity check. + VERIFY( (test_category()) ); +} + +int main() +{ + test01(); + return 0; +} diff --git a/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/typedefs.cc b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/typedefs.cc new file mode 100644 index 00000000000..16bf98e6e6c --- /dev/null +++ b/libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/typedefs.cc @@ -0,0 +1,36 @@ +// 2004-12-03 Paolo Carlini +// +// Copyright (C) 2004 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, 59 Temple Place - Suite 330, Boston, MA 02111-1307, +// USA. + +// +// NB: This file is for testing tr1/type_traits with NO OTHER INCLUDES. + +#include + +// { dg-do compile } + +void test01() +{ + // Check for required typedefs + typedef std::tr1::is_void 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; +}