1 | // (C) Copyright Jonathan Turkanis 2004. |
---|---|
2 | // Use, modification and distribution are subject to the |
3 | // Boost Software License, Version 1.0. (See accompanying file |
4 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
5 | |
6 | // See http://www.boost.org for most recent version including documentation. |
7 | |
8 | // note: this is a compile only test. |
9 | |
10 | #include <boost/config.hpp> // BOOST_STATIC_CONST |
11 | #include <boost/static_assert.hpp> |
12 | #include <boost/type_traits/is_polymorphic.hpp> |
13 | |
14 | #include <boost/serialization/static_warning.hpp> |
15 | |
16 | typedef char a1[2]; |
17 | typedef char a2[3]; |
18 | |
19 | class polymorphic { |
20 | virtual ~polymorphic(); |
21 | }; |
22 | |
23 | class non_polymorphic { |
24 | }; |
25 | |
26 | template<class T> |
27 | int f(){ |
28 | BOOST_STATIC_WARNING(T::value); |
29 | return 0; |
30 | } |
31 | |
32 | struct A { |
33 | BOOST_STATIC_CONSTANT(bool, value = false); |
34 | }; |
35 | |
36 | ///////////////////////////////////////////////////////////////////////// |
37 | // compilation of this program should show a total of 10 warning messages |
38 | |
39 | // should show NO warning message |
40 | BOOST_STATIC_WARNING(true); |
41 | |
42 | // the following should show 5 warning message |
43 | int x = f<A>(); // Warn |
44 | int y = f<boost::is_polymorphic<non_polymorphic> >(); // Warn. |
45 | int z = f<boost::is_polymorphic<polymorphic> >(); |
46 | |
47 | BOOST_STATIC_WARNING(sizeof(a1) == sizeof(a2)); // Warn. |
48 | BOOST_STATIC_WARNING(sizeof(a1) != sizeof(a1)); // Warn. |
49 | BOOST_STATIC_WARNING(! boost::is_polymorphic<polymorphic>::value); // Warn. |
50 | BOOST_STATIC_WARNING(boost::is_polymorphic<non_polymorphic>::value); // Warn. |
51 | |
52 | int main(int /* argc */, char * /* argv */[]){ |
53 | // should show NO warning message |
54 | BOOST_STATIC_WARNING(true); |
55 | |
56 | // the following should show 5 warning message |
57 | f<A>(); |
58 | BOOST_STATIC_WARNING(sizeof(a1) == sizeof(a2)); // Warn. |
59 | BOOST_STATIC_WARNING(sizeof(a1) != sizeof(a1)); // Warn. |
60 | BOOST_STATIC_WARNING(! boost::is_polymorphic<polymorphic>::value); // Warn. |
61 | BOOST_STATIC_WARNING(boost::is_polymorphic<non_polymorphic>::value); // Warn. |
62 | return 0; |
63 | } |
64 |