Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_33_1/libs/mpl/test/has_xxx.cpp @ 12

Last change on this file since 12 was 12, checked in by landauf, 17 years ago

added boost

File size: 2.5 KB
Line 
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
18BOOST_MPL_HAS_XXX_TRAIT_DEF(xxx)
19
20struct a1 {};
21struct a2 { void xxx(); };
22struct a3 { int xxx; };
23struct a4 { static int xxx(); };
24struct a5 { template< typename T > struct xxx {}; };
25
26struct b1 { typedef int xxx; };
27struct b2 { struct xxx; };
28struct b3 { typedef int& xxx; };
29struct b4 { typedef int* xxx; };
30struct b5 { typedef int xxx[10]; };
31struct b6 { typedef void (*xxx)(); };
32struct b7 { typedef void (xxx)(); };
33
34template< typename T > struct outer;
35template< 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
39template< typename T > struct xxx;
40
41
42MPL_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}
Note: See TracBrowser for help on using the repository browser.