type_traits: New.

2004-12-04  Paolo Carlini  <pcarlini@suse.de>

	* 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
This commit is contained in:
Paolo Carlini 2004-12-04 09:08:42 +00:00 committed by Paolo Carlini
parent bad1f4626e
commit 493bc46004
20 changed files with 1088 additions and 2 deletions

View File

@ -1,3 +1,40 @@
2004-12-04 Paolo Carlini <pcarlini@suse.de>
* 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 <pcarlini@suse.de>
* testsuite/testsuite_io.h (class sync_buf): New, templatized

View File

@ -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.

View File

@ -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.

View File

@ -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 <bits/c++config.h>
#include <cstddef>
//namespace std::tr1
namespace std
{
namespace tr1
{
/// @brief helper classes [4.3].
template<typename _Tp, _Tp __v>
struct integral_constant
{
static const _Tp value = __v;
typedef _Tp value_type;
typedef integral_constant<_Tp, __v> type;
};
typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> 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<typename>
struct is_void
: public false_type { };
_DEFINE_PRIMARY_SPEC(is_void, void)
template<typename>
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<typename>
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<typename>
struct is_array
: public false_type { };
template<typename _Tp, std::size_t _Size>
struct is_array<_Tp[_Size]>
: public true_type { };
template<typename _Tp>
struct is_array<_Tp[]>
: public true_type { };
template<typename _Tp>
struct is_pointer;
template<typename _Tp>
struct is_reference;
template<typename _Tp>
struct is_member_object_pointer;
template<typename _Tp>
struct is_member_function_pointer;
template<typename _Tp>
struct is_enum;
template<typename _Tp>
struct is_union;
template<typename _Tp>
struct is_class;
template<typename _Tp>
struct is_function;
#undef _DEFINE_PRIMARY_SPEC_HELPER
#undef _DEFINE_PRIMARY_SPEC
/// @brief composite type traits [4.5.2].
template<typename _Tp>
struct is_arithmetic
: public integral_constant<bool, (is_integral<_Tp>::value
|| is_floating_point<_Tp>::value)>
{ };
template<typename _Tp>
struct is_fundamental
: public integral_constant<bool, (is_arithmetic<_Tp>::value
|| is_void<_Tp>::value)>
{ };
template<typename _Tp>
struct is_object
: public integral_constant<bool, !(is_function<_Tp>::value
|| is_reference<_Tp>::value
|| is_void<_Tp>::value)>
{ };
template<typename _Tp>
struct is_member_pointer
: public integral_constant<bool,
(is_member_object_pointer<_Tp>::value
|| is_member_function_pointer<_Tp>::value)>
{ };
template<typename _Tp>
struct is_scalar
: public integral_constant<bool, (is_arithmetic<_Tp>::value
|| is_enum<_Tp>::value
|| is_pointer<_Tp>::value
|| is_member_pointer<_Tp>::value)>
{ };
template<typename _Tp>
struct is_compound
: public integral_constant<bool, !is_fundamental<_Tp>::value> { };
/// @brief type properties [4.5.3].
template<typename _Tp>
struct is_const;
template<typename _Tp>
struct is_volatile;
template<typename _Tp>
struct is_pod;
template<typename _Tp>
struct is_empty;
template<typename _Tp>
struct is_polymorphic;
template<typename _Tp>
struct is_abstract;
template<typename _Tp>
struct has_trivial_constructor;
template<typename _Tp>
struct has_trivial_copy;
template<typename _Tp>
struct has_trivial_assign;
template<typename _Tp>
struct has_trivial_destructor;
template<typename _Tp>
struct has_nothrow_constructor;
template<typename _Tp>
struct has_nothrow_copy;
template<typename _Tp>
struct has_nothrow_assign;
template<typename _Tp>
struct has_virtual_destructor
: public false_type { };
template<typename _Tp>
struct is_signed;
template<typename _Tp>
struct is_unsigned;
template<typename _Tp>
struct alignment_of;
template<typename _Tp>
struct rank;
template<typename _Tp, unsigned _Uint = 0>
struct extent;
/// @brief relationships between types [4.6].
template<typename _Tp, typename _Up>
struct is_same;
template<typename _From, typename _To>
struct is_convertible;
template<typename _Base, typename _Derived>
struct is_base_of;
/// @brief const-volatile modifications [4.7.1].
template<typename _Tp>
struct remove_const;
template<typename _Tp>
struct remove_volatile;
template<typename _Tp>
struct remove_cv;
template<typename _Tp>
struct add_const;
template<typename _Tp>
struct add_volatile;
template<typename _Tp>
struct add_cv;
/// @brief reference modifications [4.7.2].
template<typename _Tp>
struct remove_reference;
template<typename _Tp>
struct add_reference;
/// @brief array modififications [4.7.3].
template<typename _Tp>
struct remove_extent;
template<typename _Tp>
struct remove_all_extents;
/// @brief pointer modifications [4.7.4].
template<typename _Tp>
struct remove_pointer;
template<typename _Tp>
struct add_pointer;
/// @brief other transformations [4.8].
template<std::size_t _Len, std::size_t _Align>
struct aligned_storage;
}
}
#endif

View File

@ -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<template<typename> class Category,
typename Type, bool Tv>
bool
test_category()
{
bool ret = true;
ret &= Category<Type>::value == Tv;
ret &= Category<Type const>::value == Tv;
ret &= Category<Type volatile>::value == Tv;
ret &= Category<Type const volatile>::value == Tv;
ret &= Category<Type>::type::value == Tv;
ret &= Category<Type const>::type::value == Tv;
ret &= Category<Type volatile>::type::value == Tv;
ret &= Category<Type const volatile>::type::value == Tv;
return ret;
}
}; // namespace __gnu_test
#endif // _GLIBCXX_TESTSUITE_TR1_H

View File

@ -0,0 +1,63 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
class ClassType { };
void test01()
{
bool test __attribute__((unused)) = true;
using std::tr1::is_arithmetic;
using __gnu_test::test_category;
VERIFY( (test_category<is_arithmetic, void, false>()) );
VERIFY( (test_category<is_arithmetic, char, true>()) );
VERIFY( (test_category<is_arithmetic, signed char, true>()) );
VERIFY( (test_category<is_arithmetic, unsigned char, true>()) );
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_arithmetic, wchar_t, true>()) );
#endif
VERIFY( (test_category<is_arithmetic, short, true>()) );
VERIFY( (test_category<is_arithmetic, unsigned short, true>()) );
VERIFY( (test_category<is_arithmetic, int, true>()) );
VERIFY( (test_category<is_arithmetic, unsigned int, true>()) );
VERIFY( (test_category<is_arithmetic, long, true>()) );
VERIFY( (test_category<is_arithmetic, unsigned long, true>()) );
VERIFY( (test_category<is_arithmetic, long long, true>()) );
VERIFY( (test_category<is_arithmetic, unsigned long long, true>()) );
VERIFY( (test_category<is_arithmetic, float, true>()) );
VERIFY( (test_category<is_arithmetic, double, true>()) );
VERIFY( (test_category<is_arithmetic, long double, true>()) );
// Sanity check.
VERIFY( (test_category<is_arithmetic, ClassType, false>()) );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,36 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::tr1::is_arithmetic<int> 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;
}

View File

@ -0,0 +1,62 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
class ClassType { };
void test01()
{
bool test __attribute__((unused)) = true;
using std::tr1::is_fundamental;
using __gnu_test::test_category;
VERIFY( (test_category<is_fundamental, void, true>()) );
VERIFY( (test_category<is_fundamental, char, true>()) );
VERIFY( (test_category<is_fundamental, signed char, true>()) );
VERIFY( (test_category<is_fundamental, unsigned char, true>()) );
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_fundamental, wchar_t, true>()) );
#endif
VERIFY( (test_category<is_fundamental, short, true>()) );
VERIFY( (test_category<is_fundamental, unsigned short, true>()) );
VERIFY( (test_category<is_fundamental, int, true>()) );
VERIFY( (test_category<is_fundamental, unsigned int, true>()) );
VERIFY( (test_category<is_fundamental, long, true>()) );
VERIFY( (test_category<is_fundamental, unsigned long, true>()) );
VERIFY( (test_category<is_fundamental, long long, true>()) );
VERIFY( (test_category<is_fundamental, unsigned long long, true>()) );
VERIFY( (test_category<is_fundamental, float, true>()) );
VERIFY( (test_category<is_fundamental, double, true>()) );
VERIFY( (test_category<is_fundamental, long double, true>()) );
// Sanity check.
VERIFY( (test_category<is_fundamental, ClassType, false>()) );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,36 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::tr1::is_fundamental<int> 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;
}

View File

@ -0,0 +1,42 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
#include <testsuite_hooks.h>
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;
}

View File

@ -0,0 +1,43 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
// { 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;
}

View File

@ -0,0 +1,36 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::tr1::integral_constant<int, 1> 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;
}

View File

@ -0,0 +1,57 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
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<is_array, int_array, true>()) );
VERIFY( (test_category<is_array, empty_int_array, true>()) );
VERIFY( (test_category<is_array, pointer_array, true>()) );
VERIFY( (test_category<is_array, empty_pointer_array, true>()) );
VERIFY( (test_category<is_array, ClassType_array, true>()) );
VERIFY( (test_category<is_array, empty_ClassType_array, true>()) );
// Sanity check.
VERIFY( (test_category<is_array, ClassType, false>()) );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,36 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::tr1::is_array<int> 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;
}

View File

@ -0,0 +1,63 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
class ClassType { };
void test01()
{
bool test __attribute__((unused)) = true;
using std::tr1::is_floating_point;
using __gnu_test::test_category;
VERIFY( (test_category<is_floating_point, void, false>()) );
VERIFY( (test_category<is_floating_point, char, false>()) );
VERIFY( (test_category<is_floating_point, signed char, false>()) );
VERIFY( (test_category<is_floating_point, unsigned char, false>()) );
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_floating_point, wchar_t, false>()) );
#endif
VERIFY( (test_category<is_floating_point, short, false>()) );
VERIFY( (test_category<is_floating_point, unsigned short, false>()) );
VERIFY( (test_category<is_floating_point, int, false>()) );
VERIFY( (test_category<is_floating_point, unsigned int, false>()) );
VERIFY( (test_category<is_floating_point, long, false>()) );
VERIFY( (test_category<is_floating_point, unsigned long, false>()) );
VERIFY( (test_category<is_floating_point, long long, false>()) );
VERIFY( (test_category<is_floating_point, unsigned long long, false>()) );
VERIFY( (test_category<is_floating_point, float, true>()) );
VERIFY( (test_category<is_floating_point, double, true>()) );
VERIFY( (test_category<is_floating_point, long double, true>()) );
// Sanity check.
VERIFY( (test_category<is_floating_point, ClassType, false>()) );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,36 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::tr1::is_floating_point<int> 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;
}

View File

@ -0,0 +1,64 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
class ClassType { };
void test01()
{
bool test __attribute__((unused)) = true;
using std::tr1::is_integral;
using __gnu_test::test_category;
VERIFY( (test_category<is_integral, void, false>()) );
VERIFY( (test_category<is_integral, char, true>()) );
VERIFY( (test_category<is_integral, signed char, true>()) );
VERIFY( (test_category<is_integral, unsigned char, true>()) );
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_integral, wchar_t, true>()) );
#endif
VERIFY( (test_category<is_integral, short, true>()) );
VERIFY( (test_category<is_integral, unsigned short, true>()) );
VERIFY( (test_category<is_integral, int, true>()) );
VERIFY( (test_category<is_integral, unsigned int, true>()) );
VERIFY( (test_category<is_integral, long, true>()) );
VERIFY( (test_category<is_integral, unsigned long, true>()) );
VERIFY( (test_category<is_integral, long long, true>()) );
VERIFY( (test_category<is_integral, unsigned long long, true>()) );
VERIFY( (test_category<is_integral, float, false>()) );
VERIFY( (test_category<is_integral, double, false>()) );
VERIFY( (test_category<is_integral, long double, false>()) );
// Sanity check.
VERIFY( (test_category<is_integral, ClassType, false>()) );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,36 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::tr1::is_integral<int> 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;
}

View File

@ -0,0 +1,63 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
class ClassType { };
void test01()
{
bool test __attribute__((unused)) = true;
using std::tr1::is_void;
using __gnu_test::test_category;
VERIFY( (test_category<is_void, void, true>()) );
VERIFY( (test_category<is_void, char, false>()) );
VERIFY( (test_category<is_void, signed char, false>()) );
VERIFY( (test_category<is_void, unsigned char, false>()) );
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_void, wchar_t, false>()) );
#endif
VERIFY( (test_category<is_void, short, false>()) );
VERIFY( (test_category<is_void, unsigned short, false>()) );
VERIFY( (test_category<is_void, int, false>()) );
VERIFY( (test_category<is_void, unsigned int, false>()) );
VERIFY( (test_category<is_void, long, false>()) );
VERIFY( (test_category<is_void, unsigned long, false>()) );
VERIFY( (test_category<is_void, long long, false>()) );
VERIFY( (test_category<is_void, unsigned long long, false>()) );
VERIFY( (test_category<is_void, float, false>()) );
VERIFY( (test_category<is_void, double, false>()) );
VERIFY( (test_category<is_void, long double, false>()) );
// Sanity check.
VERIFY( (test_category<is_void, ClassType, false>()) );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,36 @@
// 2004-12-03 Paolo Carlini <pcarlini@suse.de>
//
// 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 <tr1/type_traits>
// { dg-do compile }
void test01()
{
// Check for required typedefs
typedef std::tr1::is_void<int> 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;
}