1 | |
---|
2 | // Copyright Aleksey Gurtovoy 2000-2004 |
---|
3 | // |
---|
4 | // Distributed under the Boost Software License, Version 1.0. |
---|
5 | // (See accompanying file LICENSE_1_0.txt or copy at |
---|
6 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
7 | // |
---|
8 | // See http://www.boost.org/libs/mpl for documentation. |
---|
9 | |
---|
10 | // $Source: /cvsroot/boost/boost/libs/mpl/test/has_xxx.cpp,v $ |
---|
11 | // $Date: 2004/09/18 07:18:02 $ |
---|
12 | // $Revision: 1.4 $ |
---|
13 | |
---|
14 | #include <boost/mpl/has_xxx.hpp> |
---|
15 | #include <boost/mpl/aux_/config/workaround.hpp> |
---|
16 | #include <boost/mpl/aux_/test.hpp> |
---|
17 | |
---|
18 | BOOST_MPL_HAS_XXX_TRAIT_DEF(xxx) |
---|
19 | |
---|
20 | struct a1 {}; |
---|
21 | struct a2 { void xxx(); }; |
---|
22 | struct a3 { int xxx; }; |
---|
23 | struct a4 { static int xxx(); }; |
---|
24 | struct a5 { template< typename T > struct xxx {}; }; |
---|
25 | |
---|
26 | struct b1 { typedef int xxx; }; |
---|
27 | struct b2 { struct xxx; }; |
---|
28 | struct b3 { typedef int& xxx; }; |
---|
29 | struct b4 { typedef int* xxx; }; |
---|
30 | struct b5 { typedef int xxx[10]; }; |
---|
31 | struct b6 { typedef void (*xxx)(); }; |
---|
32 | struct b7 { typedef void (xxx)(); }; |
---|
33 | |
---|
34 | template< typename T > struct outer; |
---|
35 | template< typename T > struct inner { typedef typename T::type type; }; |
---|
36 | |
---|
37 | // agurt, 15/aug/04: make sure MWCW passes the test in presence of the following |
---|
38 | // template |
---|
39 | template< typename T > struct xxx; |
---|
40 | |
---|
41 | |
---|
42 | MPL_TEST_CASE() |
---|
43 | { |
---|
44 | MPL_ASSERT_NOT(( has_xxx<int> )); |
---|
45 | #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) |
---|
46 | MPL_ASSERT_NOT(( has_xxx<int&> )); |
---|
47 | MPL_ASSERT_NOT(( has_xxx<int*> )); |
---|
48 | MPL_ASSERT_NOT(( has_xxx<int[]> )); |
---|
49 | MPL_ASSERT_NOT(( has_xxx<int (*)()> )); |
---|
50 | |
---|
51 | MPL_ASSERT_NOT(( has_xxx<a2> )); |
---|
52 | MPL_ASSERT_NOT(( has_xxx<a3> )); |
---|
53 | MPL_ASSERT_NOT(( has_xxx<a4> )); |
---|
54 | #if !BOOST_WORKAROUND(__MWERKS__, BOOST_TESTED_AT(0x3202)) |
---|
55 | MPL_ASSERT_NOT(( has_xxx<a5> )); |
---|
56 | #endif |
---|
57 | MPL_ASSERT_NOT(( has_xxx< enum_ > )); |
---|
58 | #endif |
---|
59 | MPL_ASSERT_NOT(( has_xxx<a1> )); |
---|
60 | MPL_ASSERT_NOT(( has_xxx< outer< inner<int> > > )); |
---|
61 | MPL_ASSERT_NOT(( has_xxx< incomplete > )); |
---|
62 | MPL_ASSERT_NOT(( has_xxx< abstract > )); |
---|
63 | MPL_ASSERT_NOT(( has_xxx< noncopyable > )); |
---|
64 | |
---|
65 | MPL_ASSERT(( has_xxx<b1,true_> )); |
---|
66 | MPL_ASSERT(( has_xxx<b2,true_> )); |
---|
67 | MPL_ASSERT(( has_xxx<b3,true_> )); |
---|
68 | MPL_ASSERT(( has_xxx<b4,true_> )); |
---|
69 | MPL_ASSERT(( has_xxx<b5,true_> )); |
---|
70 | MPL_ASSERT(( has_xxx<b6,true_> )); |
---|
71 | MPL_ASSERT(( has_xxx<b7,true_> )); |
---|
72 | |
---|
73 | #if !defined(HAS_XXX_ASSERT) |
---|
74 | # define HAS_XXX_ASSERT(x) MPL_ASSERT(x) |
---|
75 | #endif |
---|
76 | |
---|
77 | HAS_XXX_ASSERT(( has_xxx<b1> )); |
---|
78 | HAS_XXX_ASSERT(( has_xxx<b2> )); |
---|
79 | HAS_XXX_ASSERT(( has_xxx<b3> )); |
---|
80 | HAS_XXX_ASSERT(( has_xxx<b4> )); |
---|
81 | HAS_XXX_ASSERT(( has_xxx<b5> )); |
---|
82 | HAS_XXX_ASSERT(( has_xxx<b6> )); |
---|
83 | HAS_XXX_ASSERT(( has_xxx<b7> )); |
---|
84 | } |
---|