type_traits_fwd.h (__is_union_or_class): Remove.
2007-04-09 Paolo Carlini <pcarlini@suse.de> * include/tr1/type_traits_fwd.h (__is_union_or_class): Remove. * include/tr1/type_traits (struct __in_array, struct __is_union_or_class, struct __is_union_or_class_helper, struct __is_empty_helper, struct __is_polymorphic_helper): Remove. (struct is_enum): Use __is_enum. (struct is_union): Use __is_union. (struct is_class): Use __is_class. (struct is_function): Adjust. (struct is_empty): Use __is_empty. (struct is_polymorphic): Use __is_polymorphic. (struct is_abstract): Use __is_abstract. (struct has_virtual_destructor): Use __has_virtual_destructor. (struct __is_base_of_helper): Use __is_base_of. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_union_or_class/typedefs.cc: Remove. * testsuite/tr1/4_metaprogramming/composite_type_traits/ is_union_or_class/is_union_or_class.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_class/typedefs.cc: New. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_class/is_class.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_union/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/primary_type_categories/ is_union/is_union.cc: Likewise. * testsuite/tr1/4_metaprogramming/type_properties/ has_virtual_destructor/typedefs.cc: Likewise. * testsuite/tr1/4_metaprogramming/type_properties/ has_virtual_destructor/has_virtual_destructor.cc: Likewise. * testsuite/util/testsuite_tr1.h (class VirtualDestructorClass): Add. * testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/ is_polymorphic.cc: Add test. From-SVN: r123675
This commit is contained in:
parent
6e6e19cbf5
commit
22931aa4a9
12 changed files with 331 additions and 204 deletions
|
@ -1,3 +1,39 @@
|
|||
2007-04-09 Paolo Carlini <pcarlini@suse.de>
|
||||
|
||||
* include/tr1/type_traits_fwd.h (__is_union_or_class): Remove.
|
||||
* include/tr1/type_traits (struct __in_array,
|
||||
struct __is_union_or_class, struct __is_union_or_class_helper,
|
||||
struct __is_empty_helper, struct __is_polymorphic_helper):
|
||||
Remove.
|
||||
(struct is_enum): Use __is_enum.
|
||||
(struct is_union): Use __is_union.
|
||||
(struct is_class): Use __is_class.
|
||||
(struct is_function): Adjust.
|
||||
(struct is_empty): Use __is_empty.
|
||||
(struct is_polymorphic): Use __is_polymorphic.
|
||||
(struct is_abstract): Use __is_abstract.
|
||||
(struct has_virtual_destructor): Use __has_virtual_destructor.
|
||||
(struct __is_base_of_helper): Use __is_base_of.
|
||||
* testsuite/tr1/4_metaprogramming/composite_type_traits/
|
||||
is_union_or_class/typedefs.cc: Remove.
|
||||
* testsuite/tr1/4_metaprogramming/composite_type_traits/
|
||||
is_union_or_class/is_union_or_class.cc: Likewise.
|
||||
* testsuite/tr1/4_metaprogramming/primary_type_categories/
|
||||
is_class/typedefs.cc: New.
|
||||
* testsuite/tr1/4_metaprogramming/primary_type_categories/
|
||||
is_class/is_class.cc: Likewise.
|
||||
* testsuite/tr1/4_metaprogramming/primary_type_categories/
|
||||
is_union/typedefs.cc: Likewise.
|
||||
* testsuite/tr1/4_metaprogramming/primary_type_categories/
|
||||
is_union/is_union.cc: Likewise.
|
||||
* testsuite/tr1/4_metaprogramming/type_properties/
|
||||
has_virtual_destructor/typedefs.cc: Likewise.
|
||||
* testsuite/tr1/4_metaprogramming/type_properties/
|
||||
has_virtual_destructor/has_virtual_destructor.cc: Likewise.
|
||||
* testsuite/util/testsuite_tr1.h (class VirtualDestructorClass): Add.
|
||||
* testsuite/tr1/4_metaprogramming/type_properties/is_polymorphic/
|
||||
is_polymorphic.cc: Add test.
|
||||
|
||||
2007-04-08 Alexey Beshenov <bav.272304@gmail.com>
|
||||
|
||||
PR libstdc++/31511
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// TR1 type_traits -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
@ -42,27 +42,13 @@ namespace std
|
|||
{
|
||||
_GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
|
||||
|
||||
// For use in __in_array and elsewhere.
|
||||
// For use in __is_convertible_simple.
|
||||
struct __sfinae_types
|
||||
{
|
||||
typedef char __one;
|
||||
typedef struct { char __arr[2]; } __two;
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
struct __in_array
|
||||
: public __sfinae_types
|
||||
{
|
||||
private:
|
||||
template<typename _Up>
|
||||
static __one __test(_Up(*)[1]);
|
||||
template<typename>
|
||||
static __two __test(...);
|
||||
|
||||
public:
|
||||
static const bool __value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
#define _DEFINE_SPEC_BODY(_Value) \
|
||||
: public integral_constant<bool, _Value> { };
|
||||
|
||||
|
@ -172,27 +158,27 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
|
|||
|
||||
template<typename _Tp>
|
||||
struct is_enum
|
||||
: public integral_constant<bool, !(is_fundamental<_Tp>::value
|
||||
|| is_array<_Tp>::value
|
||||
|| is_pointer<_Tp>::value
|
||||
|| is_reference<_Tp>::value
|
||||
|| is_member_pointer<_Tp>::value
|
||||
|| is_function<_Tp>::value
|
||||
|| __is_union_or_class<_Tp>::value)>
|
||||
: public integral_constant<bool, __is_enum(_Tp)>
|
||||
{ };
|
||||
|
||||
template<typename>
|
||||
struct is_union { };
|
||||
template<typename _Tp>
|
||||
struct is_union
|
||||
: public integral_constant<bool, __is_union(_Tp)>
|
||||
{ };
|
||||
|
||||
template<typename>
|
||||
struct is_class { };
|
||||
template<typename _Tp>
|
||||
struct is_class
|
||||
: public integral_constant<bool, __is_class(_Tp)>
|
||||
{ };
|
||||
|
||||
template<typename _Tp>
|
||||
struct is_function
|
||||
: public integral_constant<bool, !(__in_array<_Tp>::__value
|
||||
|| __is_union_or_class<_Tp>::value
|
||||
: public integral_constant<bool, !(is_void<_Tp>::value
|
||||
|| is_scalar<_Tp>::value
|
||||
|| is_array<_Tp>::value
|
||||
|| is_reference<_Tp>::value
|
||||
|| is_void<_Tp>::value)>
|
||||
|| is_union<_Tp>::value
|
||||
|| is_class<_Tp>::value)>
|
||||
{ };
|
||||
|
||||
/// @brief composite type traits [4.5.2].
|
||||
|
@ -234,26 +220,6 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
|
|||
|| is_member_function_pointer<_Tp>::value)>
|
||||
{ };
|
||||
|
||||
template<typename _Tp>
|
||||
struct __is_union_or_class_helper
|
||||
: public __sfinae_types
|
||||
{
|
||||
private:
|
||||
template<typename _Up>
|
||||
static __one __test(int _Up::*);
|
||||
template<typename>
|
||||
static __two __test(...);
|
||||
|
||||
public:
|
||||
static const bool __value = sizeof(__test<_Tp>(0)) == 1;
|
||||
};
|
||||
|
||||
// Extension.
|
||||
template<typename _Tp>
|
||||
struct __is_union_or_class
|
||||
: public integral_constant<bool, __is_union_or_class_helper<_Tp>::__value>
|
||||
{ };
|
||||
|
||||
/// @brief type properties [4.5.3].
|
||||
template<typename>
|
||||
struct is_const
|
||||
|
@ -278,64 +244,20 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
|
|||
remove_all_extents<_Tp>::type>::value)>
|
||||
{ };
|
||||
|
||||
// NB: Without compiler support we cannot tell union from class types,
|
||||
// and is_empty and is_polymorphic don't work at all with the former.
|
||||
template<typename _Tp, bool = !__is_union_or_class<_Tp>::value>
|
||||
struct __is_empty_helper
|
||||
{
|
||||
private:
|
||||
template<typename>
|
||||
struct __first { };
|
||||
template<typename _Up>
|
||||
struct __second
|
||||
: public _Up { };
|
||||
|
||||
public:
|
||||
static const bool __value = sizeof(__first<_Tp>) == sizeof(__second<_Tp>);
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
struct __is_empty_helper<_Tp, true>
|
||||
{ static const bool __value = false; };
|
||||
|
||||
template<typename _Tp>
|
||||
struct is_empty
|
||||
: public integral_constant<bool, __is_empty_helper<_Tp>::__value>
|
||||
: public integral_constant<bool, __is_empty(_Tp)>
|
||||
{ };
|
||||
|
||||
template<typename _Tp, bool = !__is_union_or_class<_Tp>::value>
|
||||
struct __is_polymorphic_helper
|
||||
{
|
||||
private:
|
||||
template<typename _Up>
|
||||
struct __first
|
||||
: public _Up { };
|
||||
template<typename _Up>
|
||||
struct __second
|
||||
: public _Up
|
||||
{
|
||||
virtual void __dummy();
|
||||
virtual ~__second() throw();
|
||||
};
|
||||
|
||||
public:
|
||||
static const bool __value = sizeof(__first<_Tp>) == sizeof(__second<_Tp>);
|
||||
};
|
||||
|
||||
template<typename _Tp>
|
||||
struct __is_polymorphic_helper<_Tp, true>
|
||||
{ static const bool __value = false; };
|
||||
|
||||
template<typename _Tp>
|
||||
struct is_polymorphic
|
||||
: public integral_constant<bool, __is_polymorphic_helper<_Tp>::__value>
|
||||
: public integral_constant<bool, __is_polymorphic(_Tp)>
|
||||
{ };
|
||||
|
||||
// Exploit the resolution DR core/337.
|
||||
template<typename _Tp>
|
||||
struct is_abstract
|
||||
: public integral_constant<bool, (!__in_array<_Tp>::__value
|
||||
&& __is_union_or_class<_Tp>::value)> { };
|
||||
: public integral_constant<bool, __is_abstract(_Tp)>
|
||||
{ };
|
||||
|
||||
template<typename _Tp>
|
||||
struct has_trivial_constructor
|
||||
|
@ -365,9 +287,10 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
|
|||
struct has_nothrow_assign
|
||||
: public integral_constant<bool, is_pod<_Tp>::value> { };
|
||||
|
||||
template<typename>
|
||||
template<typename _Tp>
|
||||
struct has_virtual_destructor
|
||||
: public false_type { };
|
||||
: public integral_constant<bool, __has_virtual_destructor(_Tp)>
|
||||
{ };
|
||||
|
||||
template<typename>
|
||||
struct is_signed
|
||||
|
@ -430,37 +353,17 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
|
|||
struct is_same<_Tp, _Tp>
|
||||
: public true_type { };
|
||||
|
||||
// See Daveed Vandevoorde explanation in http://tinyurl.com/502f.
|
||||
// Also see Rani Sharoni in http://tinyurl.com/6jvyq.
|
||||
template<typename _Base, typename _Derived,
|
||||
bool = (!__is_union_or_class<_Base>::value
|
||||
|| !__is_union_or_class<_Derived>::value
|
||||
|| is_same<_Base, _Derived>::value)>
|
||||
struct __is_base_of_helper
|
||||
: public __sfinae_types
|
||||
{
|
||||
private:
|
||||
typedef typename remove_cv<_Base>::type _NoCv_Base;
|
||||
typedef typename remove_cv<_Derived>::type _NoCv_Derived;
|
||||
|
||||
template<typename _Up>
|
||||
static __one __test(_NoCv_Derived&, _Up);
|
||||
static __two __test(_NoCv_Base&, int);
|
||||
|
||||
struct _Conv
|
||||
{
|
||||
operator _NoCv_Derived&();
|
||||
operator _NoCv_Base&() const;
|
||||
};
|
||||
|
||||
public:
|
||||
static const bool __value = sizeof(__test(_Conv(), 0)) == 1;
|
||||
};
|
||||
|
||||
template<typename _Base, typename _Derived>
|
||||
struct __is_base_of_helper<_Base, _Derived, true>
|
||||
{ static const bool __value = is_same<_Base, _Derived>::value; };
|
||||
|
||||
struct __is_base_of_helper
|
||||
{
|
||||
typedef typename remove_cv<_Base>::type _NoCv_Base;
|
||||
typedef typename remove_cv<_Derived>::type _NoCv_Derived;
|
||||
static const bool __value = (is_same<_Base, _Derived>::value
|
||||
|| (__is_base_of(_Base, _Derived)
|
||||
&& !is_same<_NoCv_Base,
|
||||
_NoCv_Derived>::value));
|
||||
};
|
||||
|
||||
template<typename _Base, typename _Derived>
|
||||
struct is_base_of
|
||||
: public integral_constant<bool,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// TR1 type_traits -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
@ -104,10 +104,6 @@ _GLIBCXX_BEGIN_NAMESPACE(_GLIBCXX_TR1)
|
|||
template<typename _Tp>
|
||||
struct is_member_pointer;
|
||||
|
||||
// Extension.
|
||||
template<typename _Tp>
|
||||
struct __is_union_or_class;
|
||||
|
||||
/// @brief type properties [4.5.3].
|
||||
template<typename _Tp>
|
||||
struct is_const;
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
// 2005-02-25 Paolo Carlini <pcarlini@suse.de>
|
||||
//
|
||||
// Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// 4.5.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_union_or_class;
|
||||
using namespace __gnu_test;
|
||||
|
||||
// Positive tests.
|
||||
VERIFY( (test_category<__is_union_or_class, UnionType>(true)) );
|
||||
VERIFY( (test_category<__is_union_or_class, ClassType>(true)) );
|
||||
VERIFY( (test_category<__is_union_or_class, DerivedType>(true)) );
|
||||
VERIFY( (test_category<__is_union_or_class, ConvType>(true)) );
|
||||
VERIFY( (test_category<__is_union_or_class, AbstractClass>(true)) );
|
||||
VERIFY( (test_category<__is_union_or_class, PolymorphicClass>(true)) );
|
||||
VERIFY( (test_category<__is_union_or_class, DerivedPolymorphic>(true)) );
|
||||
|
||||
// Negative tests.
|
||||
VERIFY( (test_category<__is_union_or_class, void>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, int>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, float>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, int[2]>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, int*>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, int(*)(int)>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, float&>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, float(&)(float)>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, int (ClassType::*)>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class,
|
||||
int (ClassType::*) (int)>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, int (int)>(false)) );
|
||||
VERIFY( (test_category<__is_union_or_class, EnumType>(false)) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
|
||||
//
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// 4.5.1 Primary type categories
|
||||
|
||||
#include <tr1/type_traits>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_tr1.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using std::tr1::is_class;
|
||||
using namespace __gnu_test;
|
||||
|
||||
// Positive tests.
|
||||
VERIFY( (test_category<is_class, ClassType>(true)) );
|
||||
VERIFY( (test_category<is_class, DerivedType>(true)) );
|
||||
VERIFY( (test_category<is_class, ConvType>(true)) );
|
||||
VERIFY( (test_category<is_class, AbstractClass>(true)) );
|
||||
VERIFY( (test_category<is_class, PolymorphicClass>(true)) );
|
||||
VERIFY( (test_category<is_class, DerivedPolymorphic>(true)) );
|
||||
|
||||
// Negative tests.
|
||||
VERIFY( (test_category<is_class, UnionType>(false)) );
|
||||
VERIFY( (test_category<is_class, void>(false)) );
|
||||
VERIFY( (test_category<is_class, int>(false)) );
|
||||
VERIFY( (test_category<is_class, float>(false)) );
|
||||
VERIFY( (test_category<is_class, int[2]>(false)) );
|
||||
VERIFY( (test_category<is_class, int*>(false)) );
|
||||
VERIFY( (test_category<is_class, int(*)(int)>(false)) );
|
||||
VERIFY( (test_category<is_class, float&>(false)) );
|
||||
VERIFY( (test_category<is_class, float(&)(float)>(false)) );
|
||||
VERIFY( (test_category<is_class, int (ClassType::*)>(false)) );
|
||||
VERIFY( (test_category<is_class, int (ClassType::*) (int)>(false)) );
|
||||
VERIFY( (test_category<is_class, int (int)>(false)) );
|
||||
VERIFY( (test_category<is_class, EnumType>(false)) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
// 2005-02-25 Paolo Carlini <pcarlini@suse.de>
|
||||
// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
|
||||
//
|
||||
// Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
@ -28,7 +28,7 @@
|
|||
void test01()
|
||||
{
|
||||
// Check for required typedefs
|
||||
typedef std::tr1::__is_union_or_class<int> test_type;
|
||||
typedef std::tr1::is_class<int> test_type;
|
||||
typedef test_type::value_type value_type;
|
||||
typedef test_type::type type;
|
||||
typedef test_type::type::value_type type_value_type;
|
|
@ -0,0 +1,61 @@
|
|||
// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
|
||||
//
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// 4.5.1 Primary type categories
|
||||
|
||||
#include <tr1/type_traits>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_tr1.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using std::tr1::is_union;
|
||||
using namespace __gnu_test;
|
||||
|
||||
// Positive tests.
|
||||
VERIFY( (test_category<is_union, UnionType>(true)) );
|
||||
|
||||
// Negative tests.
|
||||
VERIFY( (test_category<is_union, ClassType>(false)) );
|
||||
VERIFY( (test_category<is_union, DerivedType>(false)) );
|
||||
VERIFY( (test_category<is_union, ConvType>(false)) );
|
||||
VERIFY( (test_category<is_union, AbstractClass>(false)) );
|
||||
VERIFY( (test_category<is_union, PolymorphicClass>(false)) );
|
||||
VERIFY( (test_category<is_union, DerivedPolymorphic>(false)) );
|
||||
VERIFY( (test_category<is_union, void>(false)) );
|
||||
VERIFY( (test_category<is_union, int>(false)) );
|
||||
VERIFY( (test_category<is_union, float>(false)) );
|
||||
VERIFY( (test_category<is_union, int[2]>(false)) );
|
||||
VERIFY( (test_category<is_union, int*>(false)) );
|
||||
VERIFY( (test_category<is_union, int(*)(int)>(false)) );
|
||||
VERIFY( (test_category<is_union, float&>(false)) );
|
||||
VERIFY( (test_category<is_union, float(&)(float)>(false)) );
|
||||
VERIFY( (test_category<is_union, int (ClassType::*)>(false)) );
|
||||
VERIFY( (test_category<is_union, int (ClassType::*) (int)>(false)) );
|
||||
VERIFY( (test_category<is_union, int (int)>(false)) );
|
||||
VERIFY( (test_category<is_union, EnumType>(false)) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
|
||||
//
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
//
|
||||
// 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_union<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;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
|
||||
//
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
// 4.5.3 Type properties
|
||||
|
||||
#include <tr1/type_traits>
|
||||
#include <iostream>
|
||||
#include <testsuite_hooks.h>
|
||||
#include <testsuite_tr1.h>
|
||||
|
||||
void test01()
|
||||
{
|
||||
bool test __attribute__((unused)) = true;
|
||||
using std::tr1::has_virtual_destructor;
|
||||
using namespace __gnu_test;
|
||||
|
||||
// Positive tests.
|
||||
VERIFY( (test_category<has_virtual_destructor,
|
||||
VirtualDestructorClass>(true)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, std::iostream>(true)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, std::streambuf>(true)) );
|
||||
|
||||
// Negative tests.
|
||||
VERIFY( (test_category<has_virtual_destructor, PolymorphicClass>(false)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, DerivedPolymorphic>(false)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, AbstractClass>(false)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, void>(false)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, int (int)>(false)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, int&>(false)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, EnumType>(false)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, ClassType>(false)) );
|
||||
VERIFY( (test_category<has_virtual_destructor, DerivedType>(false)) );
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test01();
|
||||
return 0;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
// 2007-04-08 Paolo Carlini <pcarlini@suse.de>
|
||||
//
|
||||
// Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
// terms of the GNU General Public License as published by the
|
||||
// Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along
|
||||
// with this library; see the file COPYING. If not, write to the Free
|
||||
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
||||
// USA.
|
||||
|
||||
//
|
||||
// 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::has_virtual_destructor<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;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
// 2005-03-03 Paolo Carlini <pcarlini@suse.de>
|
||||
//
|
||||
// Copyright (C) 2005 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
@ -35,6 +35,7 @@ void test01()
|
|||
VERIFY( (test_category<is_polymorphic, PolymorphicClass>(true)) );
|
||||
VERIFY( (test_category<is_polymorphic, DerivedPolymorphic>(true)) );
|
||||
VERIFY( (test_category<is_polymorphic, AbstractClass>(true)) );
|
||||
VERIFY( (test_category<is_polymorphic, VirtualDestructorClass>(true)) );
|
||||
VERIFY( (test_category<is_polymorphic, std::iostream>(true)) );
|
||||
VERIFY( (test_category<is_polymorphic, std::streambuf>(true)) );
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
// -*- C++ -*-
|
||||
// Testing utilities for the tr1 testsuite.
|
||||
//
|
||||
// Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
|
@ -103,17 +103,20 @@ namespace __gnu_test
|
|||
class AbstractClass
|
||||
{
|
||||
virtual void rotate(int) = 0;
|
||||
virtual ~AbstractClass();
|
||||
};
|
||||
|
||||
class PolymorphicClass
|
||||
{
|
||||
virtual void rotate(int);
|
||||
virtual ~PolymorphicClass();
|
||||
};
|
||||
|
||||
class DerivedPolymorphic : public PolymorphicClass { };
|
||||
|
||||
class VirtualDestructorClass
|
||||
{
|
||||
virtual ~VirtualDestructorClass();
|
||||
};
|
||||
|
||||
union UnionType { };
|
||||
|
||||
class IncompleteClass;
|
||||
|
|
Loading…
Add table
Reference in a new issue