type_traits: Implement rank.

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

	* include/tr1/type_traits: Implement rank.
	* testsuite/testsuite_tr1.h (test_property): Generalize to any
	value_type.
	(test_category, test_relationship): Slightly tweak consistently.
	* testsuite/tr1/4_metaprogramming/type_properties/rank/
	rank.cc: New.
	* testsuite/tr1/4_metaprogramming/type_properties/rank/
	typedefs.cc: Likewise.

	* testsuite/tr1/4_metaprogramming/composite_type_traits/
	is_compound/is_compound.cc: New.
	* testsuite/tr1/4_metaprogramming/composite_type_traits/
	is_compound/typedefs.cc: Likewise.

	* testsuite/tr1/4_metaprogramming/composite_type_traits/
	is_arithmetic/is_arithmetic.cc: Tweak consistently with the
	testsuite_tr1.h changes.
	* testsuite/tr1/4_metaprogramming/composite_type_traits/
	is_fundamental/is_fundamental.cc: Likewise.
	* testsuite/tr1/4_metaprogramming/primary_type_categories/
	is_array/is_array.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_integral/is_integral.cc: Likewise.
	* testsuite/tr1/4_metaprogramming/primary_type_categories/
	is_reference/is_reference.cc: Likewise.
	* testsuite/tr1/4_metaprogramming/primary_type_categories/
	is_void/is_void.cc: Likewise.
	* testsuite/tr1/4_metaprogramming/relationships_between_types/
	is_same/is_same.cc: Likewise.
	* testsuite/tr1/4_metaprogramming/type_properties/is_const/
	is_const.cc: Likewise.
	* testsuite/tr1/4_metaprogramming/type_properties/is_volatile/
	is_volatile.cc: Likewise.

From-SVN: r92033
This commit is contained in:
Paolo Carlini 2004-12-11 21:46:27 +00:00 committed by Paolo Carlini
parent 343f6bbf97
commit db5ff2363d
17 changed files with 375 additions and 149 deletions

View File

@ -1,3 +1,41 @@
2004-12-11 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits: Implement rank.
* testsuite/testsuite_tr1.h (test_property): Generalize to any
value_type.
(test_category, test_relationship): Slightly tweak consistently.
* testsuite/tr1/4_metaprogramming/type_properties/rank/
rank.cc: New.
* testsuite/tr1/4_metaprogramming/type_properties/rank/
typedefs.cc: Likewise.
* testsuite/tr1/4_metaprogramming/composite_type_traits/
is_compound/is_compound.cc: New.
* testsuite/tr1/4_metaprogramming/composite_type_traits/
is_compound/typedefs.cc: Likewise.
* testsuite/tr1/4_metaprogramming/composite_type_traits/
is_arithmetic/is_arithmetic.cc: Tweak consistently with the
testsuite_tr1.h changes.
* testsuite/tr1/4_metaprogramming/composite_type_traits/
is_fundamental/is_fundamental.cc: Likewise.
* testsuite/tr1/4_metaprogramming/primary_type_categories/
is_array/is_array.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_integral/is_integral.cc: Likewise.
* testsuite/tr1/4_metaprogramming/primary_type_categories/
is_reference/is_reference.cc: Likewise.
* testsuite/tr1/4_metaprogramming/primary_type_categories/
is_void/is_void.cc: Likewise.
* testsuite/tr1/4_metaprogramming/relationships_between_types/
is_same/is_same.cc: Likewise.
* testsuite/tr1/4_metaprogramming/type_properties/is_const/
is_const.cc: Likewise.
* testsuite/tr1/4_metaprogramming/type_properties/is_volatile/
is_volatile.cc: Likewise.
2004-12-10 Paolo Carlini <pcarlini@suse.de>
* include/tr1/type_traits: Implement remove_const, remove_volatile,

View File

@ -233,8 +233,17 @@ namespace tr1
template<typename _Tp>
struct alignment_of;
template<typename>
struct rank
: public integral_constant<std::size_t, 0> { };
template<typename _Tp, std::size_t _Size>
struct rank<_Tp[_Size]>
: public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
template<typename _Tp>
struct rank;
struct rank<_Tp[]>
: public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
template<typename _Tp, unsigned _Uint = 0>
struct extent;
@ -324,25 +333,25 @@ namespace tr1
template<typename _Tp>
struct remove_extent
{
typedef _Tp type;
typedef _Tp type;
};
template<typename _Tp, std::size_t _Size>
struct remove_extent<_Tp[_Size]>
{
typedef _Tp type;
typedef _Tp type;
};
template<typename _Tp>
struct remove_extent<_Tp[]>
{
typedef _Tp type;
typedef _Tp type;
};
template<typename _Tp>
struct remove_all_extents
{
typedef _Tp type;
typedef _Tp type;
};
template<typename _Tp, std::size_t _Size>

View File

@ -35,41 +35,41 @@ namespace __gnu_test
{
// For tr1/type_traits.
template<template<typename> class Category,
typename Type, bool Tv>
typename Type>
bool
test_category()
test_category(bool value)
{
bool ret = true;
ret &= Category<Type>::value == Tv;
ret &= Category<const Type>::value == Tv;
ret &= Category<volatile Type>::value == Tv;
ret &= Category<const volatile Type>::value == Tv;
ret &= Category<Type>::type::value == Tv;
ret &= Category<const Type>::type::value == Tv;
ret &= Category<volatile Type>::type::value == Tv;
ret &= Category<const volatile Type>::type::value == Tv;
ret &= Category<Type>::value == value;
ret &= Category<const Type>::value == value;
ret &= Category<volatile Type>::value == value;
ret &= Category<const volatile Type>::value == value;
ret &= Category<Type>::type::value == value;
ret &= Category<const Type>::type::value == value;
ret &= Category<volatile Type>::type::value == value;
ret &= Category<const volatile Type>::type::value == value;
return ret;
}
template<template<typename> class Property,
typename Type, bool Tv>
typename Type>
bool
test_property()
test_property(typename Property<Type>::value_type value)
{
bool ret = true;
ret &= Property<Type>::value == Tv;
ret &= Property<Type>::type::value == Tv;
ret &= Property<Type>::value == value;
ret &= Property<Type>::type::value == value;
return ret;
}
template<template<typename, typename> class Relationship,
typename Type1, typename Type2, bool Tv>
typename Type1, typename Type2>
bool
test_relationship()
test_relationship(bool value)
{
bool ret = true;
ret &= Relationship<Type1, Type2>::value == Tv;
ret &= Relationship<Type1, Type2>::type::value == Tv;
ret &= Relationship<Type1, Type2>::value == value;
ret &= Relationship<Type1, Type2>::type::value == value;
return ret;
}

View File

@ -30,28 +30,28 @@ void test01()
using std::tr1::is_arithmetic;
using namespace __gnu_test;
VERIFY( (test_category<is_arithmetic, void, false>()) );
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>()) );
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>()) );
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>()) );
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>()) );
VERIFY( (test_category<is_arithmetic, ClassType>(false)) );
}
int main()

View File

@ -0,0 +1,60 @@
// 2004-12-11 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>
void test01()
{
bool test __attribute__((unused)) = true;
using std::tr1::is_compound;
using namespace __gnu_test;
VERIFY( (test_category<is_compound, void>(false)) );
VERIFY( (test_category<is_compound, char>(false)) );
VERIFY( (test_category<is_compound, signed char>(false)) );
VERIFY( (test_category<is_compound, unsigned char>(false)) );
#ifdef _GLIBCXX_USE_WCHAR_T
VERIFY( (test_category<is_compound, wchar_t>(false)) );
#endif
VERIFY( (test_category<is_compound, short>(false)) );
VERIFY( (test_category<is_compound, unsigned short>(false)) );
VERIFY( (test_category<is_compound, int>(false)) );
VERIFY( (test_category<is_compound, unsigned int>(false)) );
VERIFY( (test_category<is_compound, long>(false)) );
VERIFY( (test_category<is_compound, unsigned long>(false)) );
VERIFY( (test_category<is_compound, long long>(false)) );
VERIFY( (test_category<is_compound, unsigned long long>(false)) );
VERIFY( (test_category<is_compound, float>(false)) );
VERIFY( (test_category<is_compound, double>(false)) );
VERIFY( (test_category<is_compound, long double>(false)) );
// Sanity check.
VERIFY( (test_category<is_compound, ClassType>(true)) );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,36 @@
// 2004-12-11 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_compound<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

@ -30,27 +30,27 @@ void test01()
using std::tr1::is_fundamental;
using namespace __gnu_test;
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>()) );
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>()) );
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>()) );
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>()) );
VERIFY( (test_category<is_fundamental, ClassType>(false)) );
}
int main()

View File

@ -30,21 +30,21 @@ void test01()
using std::tr1::is_array;
using namespace __gnu_test;
VERIFY( (test_category<is_array, int[2], true>()) );
VERIFY( (test_category<is_array, int[], true>()) );
VERIFY( (test_category<is_array, int[2][3], true>()) );
VERIFY( (test_category<is_array, int[][3], true>()) );
VERIFY( (test_category<is_array, float*[2], true>()) );
VERIFY( (test_category<is_array, float*[], true>()) );
VERIFY( (test_category<is_array, float*[2][3], true>()) );
VERIFY( (test_category<is_array, float*[][3], true>()) );
VERIFY( (test_category<is_array, ClassType[2], true>()) );
VERIFY( (test_category<is_array, ClassType[], true>()) );
VERIFY( (test_category<is_array, ClassType[2][3], true>()) );
VERIFY( (test_category<is_array, ClassType[][3], true>()) );
VERIFY( (test_category<is_array, int[2]>(true)) );
VERIFY( (test_category<is_array, int[]>(true)) );
VERIFY( (test_category<is_array, int[2][3]>(true)) );
VERIFY( (test_category<is_array, int[][3]>(true)) );
VERIFY( (test_category<is_array, float*[2]>(true)) );
VERIFY( (test_category<is_array, float*[]>(true)) );
VERIFY( (test_category<is_array, float*[2][3]>(true)) );
VERIFY( (test_category<is_array, float*[][3]>(true)) );
VERIFY( (test_category<is_array, ClassType[2]>(true)) );
VERIFY( (test_category<is_array, ClassType[]>(true)) );
VERIFY( (test_category<is_array, ClassType[2][3]>(true)) );
VERIFY( (test_category<is_array, ClassType[][3]>(true)) );
// Sanity check.
VERIFY( (test_category<is_array, ClassType, false>()) );
VERIFY( (test_category<is_array, ClassType>(false)) );
}
int main()

View File

@ -30,28 +30,28 @@ void test01()
using std::tr1::is_floating_point;
using namespace __gnu_test;
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>()) );
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>()) );
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, 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>()) );
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>()) );
VERIFY( (test_category<is_floating_point, ClassType>(false)) );
}
int main()

View File

@ -30,29 +30,29 @@ void test01()
using std::tr1::is_integral;
using namespace __gnu_test;
VERIFY( (test_category<is_integral, void, false>()) );
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>()) );
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>()) );
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, 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>()) );
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>()) );
VERIFY( (test_category<is_integral, ClassType>(false)) );
}
int main()

View File

@ -34,12 +34,12 @@ void test01()
typedef ClassType& ClassType_ref;
typedef int (&fun_ref) (int);
VERIFY( (test_category<is_reference, int_ref, true>()) );
VERIFY( (test_category<is_reference, ClassType_ref, true>()) );
VERIFY( (test_category<is_reference, fun_ref, true>()) );
VERIFY( (test_category<is_reference, int_ref>(true)) );
VERIFY( (test_category<is_reference, ClassType_ref>(true)) );
VERIFY( (test_category<is_reference, fun_ref>(true)) );
// Sanity check.
VERIFY( (test_category<is_reference, ClassType, false>()) );
VERIFY( (test_category<is_reference, ClassType>(false)) );
}
int main()

View File

@ -30,28 +30,28 @@ void test01()
using std::tr1::is_void;
using namespace __gnu_test;
VERIFY( (test_category<is_void, void, true>()) );
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>()) );
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>()) );
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>()) );
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>()) );
VERIFY( (test_category<is_void, ClassType>(false)) );
}
int main()

View File

@ -31,16 +31,16 @@ void test01()
using namespace __gnu_test;
// Positive tests.
VERIFY( (test_relationship<is_same, int, int, true>()) );
VERIFY( (test_relationship<is_same, const int, const int, true>()) );
VERIFY( (test_relationship<is_same, int&, int&, true>()) );
VERIFY( (test_relationship<is_same, ClassType, ClassType, true>()) );
VERIFY( (test_relationship<is_same, int, int>(true)) );
VERIFY( (test_relationship<is_same, const int, const int>(true)) );
VERIFY( (test_relationship<is_same, int&, int&>(true)) );
VERIFY( (test_relationship<is_same, ClassType, ClassType>(true)) );
// Negative tests.
VERIFY( (test_relationship<is_same, void, int, false>()) );
VERIFY( (test_relationship<is_same, int, const int, false>()) );
VERIFY( (test_relationship<is_same, int, int&, false>()) );
VERIFY( (test_relationship<is_same, int, ClassType, false>()) );
VERIFY( (test_relationship<is_same, void, int>(false)) );
VERIFY( (test_relationship<is_same, int, const int>(false)) );
VERIFY( (test_relationship<is_same, int, int&>(false)) );
VERIFY( (test_relationship<is_same, int, ClassType>(false)) );
}
int main()

View File

@ -31,16 +31,16 @@ void test01()
using namespace __gnu_test;
// Positive tests.
VERIFY( (test_property<is_const, const int, true>()) );
VERIFY( (test_property<is_const, const volatile int, true>()) );
VERIFY( (test_property<is_const, cClassType, true>()) );
VERIFY( (test_property<is_const, cvClassType, true>()) );
VERIFY( (test_property<is_const, const int>(true)) );
VERIFY( (test_property<is_const, const volatile int>(true)) );
VERIFY( (test_property<is_const, cClassType>(true)) );
VERIFY( (test_property<is_const, cvClassType>(true)) );
// Negative tests.
VERIFY( (test_property<is_const, int, false>()) );
VERIFY( (test_property<is_const, volatile int, false>()) );
VERIFY( (test_property<is_const, ClassType, false>()) );
VERIFY( (test_property<is_const, vClassType, false>()) );
VERIFY( (test_property<is_const, int>(false)) );
VERIFY( (test_property<is_const, volatile int>(false)) );
VERIFY( (test_property<is_const, ClassType>(false)) );
VERIFY( (test_property<is_const, vClassType>(false)) );
}
int main()

View File

@ -31,16 +31,16 @@ void test01()
using namespace __gnu_test;
// Positive tests.
VERIFY( (test_property<is_volatile, volatile int, true>()) );
VERIFY( (test_property<is_volatile, const volatile int, true>()) );
VERIFY( (test_property<is_volatile, vClassType, true>()) );
VERIFY( (test_property<is_volatile, cvClassType, true>()) );
VERIFY( (test_property<is_volatile, volatile int>(true)) );
VERIFY( (test_property<is_volatile, const volatile int>(true)) );
VERIFY( (test_property<is_volatile, vClassType>(true)) );
VERIFY( (test_property<is_volatile, cvClassType>(true)) );
// Negative tests.
VERIFY( (test_property<is_volatile, int, false>()) );
VERIFY( (test_property<is_volatile, const int, false>()) );
VERIFY( (test_property<is_volatile, ClassType, false>()) );
VERIFY( (test_property<is_volatile, cClassType, false>()) );
VERIFY( (test_property<is_volatile, int>(false)) );
VERIFY( (test_property<is_volatile, const int>(false)) );
VERIFY( (test_property<is_volatile, ClassType>(false)) );
VERIFY( (test_property<is_volatile, cClassType>(false)) );
}
int main()

View File

@ -0,0 +1,47 @@
// 2004-12-11 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.3 Type properties
#include <tr1/type_traits>
#include <testsuite_hooks.h>
#include <testsuite_tr1.h>
void test01()
{
bool test __attribute__((unused)) = true;
using std::tr1::rank;
using namespace __gnu_test;
VERIFY( (test_property<rank, int>(0)) );
VERIFY( (test_property<rank, int[2]>(1)) );
VERIFY( (test_property<rank, int[][4]>(2)) );
VERIFY( (test_property<rank, int[2][2][4][4][6][6]>(6)) );
VERIFY( (test_property<rank, ClassType>(0)) );
VERIFY( (test_property<rank, ClassType[2]>(1)) );
VERIFY( (test_property<rank, ClassType[][4]>(2)) );
VERIFY( (test_property<rank, ClassType[2][2][4][4][6][6]>(6)) );
}
int main()
{
test01();
return 0;
}

View File

@ -0,0 +1,36 @@
// 2004-12-11 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::rank<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;
}