This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[v3] tr1/type_traits rank + testsuite work
- From: Paolo Carlini <pcarlini at suse dot de>
- To: "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 11 Dec 2004 22:43:45 +0100
- Subject: [v3] tr1/type_traits rank + testsuite work
Hi,
the implementation of rank is a tad more interesting than other
recent work. Also slightly generalized the testing framework and
added tests for is_compound.
Tested x86-linux.
Paolo.
//////////////
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.
diff -prN libstdc++-v3-orig/include/tr1/type_traits libstdc++-v3/include/tr1/type_traits
*** libstdc++-v3-orig/include/tr1/type_traits Fri Dec 10 00:18:21 2004
--- libstdc++-v3/include/tr1/type_traits Sat Dec 11 20:40:13 2004
*************** namespace tr1
*** 233,240 ****
template<typename _Tp>
struct alignment_of;
template<typename _Tp>
! struct rank;
template<typename _Tp, unsigned _Uint = 0>
struct extent;
--- 233,249 ----
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<_Tp[]>
! : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
template<typename _Tp, unsigned _Uint = 0>
struct extent;
*************** namespace tr1
*** 324,348 ****
template<typename _Tp>
struct remove_extent
{
! typedef _Tp type;
};
template<typename _Tp, std::size_t _Size>
struct remove_extent<_Tp[_Size]>
{
! typedef _Tp type;
};
template<typename _Tp>
struct remove_extent<_Tp[]>
{
! typedef _Tp type;
};
template<typename _Tp>
struct remove_all_extents
{
! typedef _Tp type;
};
template<typename _Tp, std::size_t _Size>
--- 333,357 ----
template<typename _Tp>
struct remove_extent
{
! typedef _Tp type;
};
template<typename _Tp, std::size_t _Size>
struct remove_extent<_Tp[_Size]>
{
! typedef _Tp type;
};
template<typename _Tp>
struct remove_extent<_Tp[]>
{
! typedef _Tp type;
};
template<typename _Tp>
struct remove_all_extents
{
! typedef _Tp type;
};
template<typename _Tp, std::size_t _Size>
diff -prN libstdc++-v3-orig/testsuite/testsuite_tr1.h libstdc++-v3/testsuite/testsuite_tr1.h
*** libstdc++-v3-orig/testsuite/testsuite_tr1.h Wed Dec 8 16:16:57 2004
--- libstdc++-v3/testsuite/testsuite_tr1.h Sat Dec 11 21:35:34 2004
*************** namespace __gnu_test
*** 35,75 ****
{
// 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<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;
return ret;
}
template<template<typename> class Property,
! typename Type, bool Tv>
bool
! test_property()
{
bool ret = true;
! ret &= Property<Type>::value == Tv;
! ret &= Property<Type>::type::value == Tv;
return ret;
}
template<template<typename, typename> class Relationship,
! typename Type1, typename Type2, bool Tv>
bool
! test_relationship()
{
bool ret = true;
! ret &= Relationship<Type1, Type2>::value == Tv;
! ret &= Relationship<Type1, Type2>::type::value == Tv;
return ret;
}
--- 35,75 ----
{
// For tr1/type_traits.
template<template<typename> class Category,
! typename Type>
bool
! test_category(bool value)
{
bool ret = true;
! 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
! test_property(typename Property<Type>::value_type value)
{
bool ret = true;
! ret &= Property<Type>::value == value;
! ret &= Property<Type>::type::value == value;
return ret;
}
template<template<typename, typename> class Relationship,
! typename Type1, typename Type2>
bool
! test_relationship(bool value)
{
bool ret = true;
! ret &= Relationship<Type1, Type2>::value == value;
! ret &= Relationship<Type1, Type2>::type::value == value;
return ret;
}
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/is_arithmetic.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/is_arithmetic.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/is_arithmetic.cc Tue Dec 7 13:44:52 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_arithmetic/is_arithmetic.cc Sat Dec 11 21:19:16 2004
*************** void test01()
*** 30,57 ****
using std::tr1::is_arithmetic;
using namespace __gnu_test;
! 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()
--- 30,57 ----
using std::tr1::is_arithmetic;
using namespace __gnu_test;
! 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()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/composite_type_traits/is_compound/is_compound.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_compound/is_compound.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/composite_type_traits/is_compound/is_compound.cc Thu Jan 1 01:00:00 1970
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_compound/is_compound.cc Sat Dec 11 21:20:46 2004
***************
*** 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;
+ }
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/composite_type_traits/is_compound/typedefs.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_compound/typedefs.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/composite_type_traits/is_compound/typedefs.cc Thu Jan 1 01:00:00 1970
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_compound/typedefs.cc Sat Dec 11 20:55:31 2004
***************
*** 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;
+ }
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/is_fundamental.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/is_fundamental.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/is_fundamental.cc Tue Dec 7 13:45:09 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/composite_type_traits/is_fundamental/is_fundamental.cc Sat Dec 11 21:22:06 2004
*************** void test01()
*** 30,56 ****
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>()) );
#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()
--- 30,56 ----
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)) );
#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()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/is_array.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/is_array.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/is_array.cc Thu Dec 9 23:54:29 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_array/is_array.cc Sat Dec 11 21:23:25 2004
*************** void test01()
*** 30,50 ****
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>()) );
// Sanity check.
! VERIFY( (test_category<is_array, ClassType, false>()) );
}
int main()
--- 30,50 ----
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)) );
// Sanity check.
! VERIFY( (test_category<is_array, ClassType>(false)) );
}
int main()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/is_floating_point.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/is_floating_point.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/is_floating_point.cc Tue Dec 7 13:45:39 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_floating_point/is_floating_point.cc Sat Dec 11 21:24:48 2004
*************** void test01()
*** 30,57 ****
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>()) );
#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()
--- 30,57 ----
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)) );
#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()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/is_integral.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/is_integral.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/is_integral.cc Tue Dec 7 13:45:52 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_integral/is_integral.cc Sat Dec 11 21:26:29 2004
*************** void test01()
*** 30,58 ****
using std::tr1::is_integral;
using namespace __gnu_test;
! 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()
--- 30,58 ----
using std::tr1::is_integral;
using namespace __gnu_test;
! 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()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_reference/is_reference.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_reference/is_reference.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_reference/is_reference.cc Tue Dec 7 13:46:04 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_reference/is_reference.cc Sat Dec 11 21:26:54 2004
*************** void test01()
*** 34,45 ****
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>()) );
// Sanity check.
! VERIFY( (test_category<is_reference, ClassType, false>()) );
}
int main()
--- 34,45 ----
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)) );
// Sanity check.
! VERIFY( (test_category<is_reference, ClassType>(false)) );
}
int main()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/is_void.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/is_void.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/is_void.cc Tue Dec 7 13:46:16 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/primary_type_categories/is_void/is_void.cc Sat Dec 11 21:28:16 2004
*************** void test01()
*** 30,57 ****
using std::tr1::is_void;
using namespace __gnu_test;
! 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()
--- 30,57 ----
using std::tr1::is_void;
using namespace __gnu_test;
! 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()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/relationships_between_types/is_same/is_same.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/relationships_between_types/is_same/is_same.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/relationships_between_types/is_same/is_same.cc Wed Dec 8 17:06:28 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/relationships_between_types/is_same/is_same.cc Sat Dec 11 21:29:09 2004
*************** void test01()
*** 31,46 ****
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>()) );
// 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>()) );
}
int main()
--- 31,46 ----
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)) );
// 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)) );
}
int main()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/type_properties/is_const/is_const.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_const/is_const.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/type_properties/is_const/is_const.cc Wed Dec 8 16:14:48 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_const/is_const.cc Sat Dec 11 22:04:52 2004
*************** void test01()
*** 31,46 ****
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>()) );
// 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>()) );
}
int main()
--- 31,46 ----
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)) );
// 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)) );
}
int main()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/type_properties/is_volatile/is_volatile.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_volatile/is_volatile.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/type_properties/is_volatile/is_volatile.cc Wed Dec 8 16:15:23 2004
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/is_volatile/is_volatile.cc Sat Dec 11 21:10:29 2004
*************** void test01()
*** 31,46 ****
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>()) );
// 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>()) );
}
int main()
--- 31,46 ----
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)) );
// 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)) );
}
int main()
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/type_properties/rank/rank.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/rank/rank.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/type_properties/rank/rank.cc Thu Jan 1 01:00:00 1970
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/rank/rank.cc Sat Dec 11 21:31:11 2004
***************
*** 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;
+ }
diff -prN libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/type_properties/rank/typedefs.cc libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/rank/typedefs.cc
*** libstdc++-v3-orig/testsuite/tr1/4_metaprogramming/type_properties/rank/typedefs.cc Thu Jan 1 01:00:00 1970
--- libstdc++-v3/testsuite/tr1/4_metaprogramming/type_properties/rank/typedefs.cc Sat Dec 11 20:58:40 2004
***************
*** 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;
+ }