• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Negative test for BOOST_TEST_TRAIT_SAME
3 //
4 // Copyright 2014, 2019 Peter Dimov
5 //
6 // Distributed under the Boost Software License, Version 1.0.
7 // See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt
9 //
10 
11 #include <boost/core/lightweight_test_trait.hpp>
12 #include <boost/config.hpp>
13 
14 struct X
15 {
16     typedef int type;
17 };
18 
19 template<class T1, class T2> struct Y
20 {
21     typedef T1 type;
22 };
23 
24 typedef int I1;
25 typedef const int I2;
26 typedef volatile int I3;
27 typedef const volatile int I4;
28 typedef int& I5;
29 typedef const int& I6;
30 typedef volatile int& I7;
31 typedef const volatile int& I8;
32 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
33 typedef int&& I9;
34 typedef const int&& I10;
35 typedef volatile int&& I11;
36 typedef const volatile int&& I12;
37 #endif
38 
main()39 int main()
40 {
41     BOOST_TEST_TRAIT_SAME(char[1], char[2]);
42     BOOST_TEST_TRAIT_SAME(char[1], char[]);
43     BOOST_TEST_TRAIT_SAME(char[1], char*);
44     BOOST_TEST_TRAIT_SAME(void(), void(int));
45     BOOST_TEST_TRAIT_SAME(void(), void(*)());
46     BOOST_TEST_TRAIT_SAME(X, void);
47     BOOST_TEST_TRAIT_SAME(X::type, void);
48     BOOST_TEST_TRAIT_SAME(X, Y<void, void>);
49     BOOST_TEST_TRAIT_SAME(X::type, Y<float, int>::type);
50     BOOST_TEST_TRAIT_SAME(Y<int, float>, Y<int, double>);
51     BOOST_TEST_TRAIT_SAME(I1, I2);
52     BOOST_TEST_TRAIT_SAME(I3, I4);
53     BOOST_TEST_TRAIT_SAME(I5, I6);
54     BOOST_TEST_TRAIT_SAME(I7, I8);
55 
56     int expected = 14;
57 
58 #if !defined(BOOST_NO_CXX11_RVALUE_REFERENCES)
59 
60     BOOST_TEST_TRAIT_SAME(I9, I10);
61     BOOST_TEST_TRAIT_SAME(I11, I12);
62 
63     expected += 2;
64 
65 #endif
66 
67     return boost::report_errors() == expected;
68 }
69