]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/type_traits/test/is_base_and_derived_test.cpp
2 // (C) Copyright John Maddock 2000.
3 // Use, modification and distribution are subject to the
4 // Boost Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 # include <type_traits>
11 # include <boost/type_traits/is_base_and_derived.hpp>
14 #include "check_integral_constant.hpp"
17 // Additional tests added for VC7.1 bug, 2005/04/21
22 template<class Class
,typename Type
,Type
Class::*PtrToMember
>
23 struct class_member
{};
24 template<class Class
,typename Type
,Type
Class::*PtrToMember
>
25 struct class_member2
: public marker
{};
28 TT_TEST_BEGIN(is_base_and_derived
)
30 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Derived
,Base
>::value
), false);
31 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Derived
,Derived
>::value
), false);
32 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Base
,Base
>::value
), false);
33 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<const Base
,Base
>::value
), false);
34 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Base
,Derived
>::value
), true);
35 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Base
,MultiBase
>::value
), true);
36 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Derived
,MultiBase
>::value
), true);
37 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Derived2
,MultiBase
>::value
), true);
38 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Base
,PrivateBase
>::value
), true);
39 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<NonDerived
,Base
>::value
), false);
40 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Base
,void>::value
), false);
41 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<Base
,const void>::value
), false);
42 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<void,Derived
>::value
), false);
43 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<const void,Derived
>::value
), false);
44 #if defined(TEST_STD) && (TEST_STD < 2006)
45 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<int, int>::value
), true);
46 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<const int, int>::value
), true);
48 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<int, int>::value
), false);
49 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<const int, int>::value
), false);
51 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<VB
,VD
>::value
), true);
52 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<VD
,VB
>::value
), false);
53 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<test_abc1
,test_abc3
>::value
), true);
54 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<test_abc3
,test_abc1
>::value
), false);
56 typedef class_member
<foo
,int,&foo::x
> mem_type
;
57 typedef class_member2
<foo
,int,&foo::x
> mem2_type
;
58 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<marker
, mem_type
>::value
), false);
59 BOOST_CHECK_INTEGRAL_CONSTANT((::tt::is_base_and_derived
<marker
, mem2_type
>::value
), true);