| 1 | // Copyright 2021 Peter Dimov |
|---|---|
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // https://www.boost.org/LICENSE_1_0.txt |
| 4 | |
| 5 | #include <boost/describe/members.hpp> |
| 6 | #include <boost/describe/class.hpp> |
| 7 | #include <boost/core/lightweight_test_trait.hpp> |
| 8 | |
| 9 | #if !defined(BOOST_DESCRIBE_CXX11) |
| 10 | |
| 11 | #include <boost/config/pragma_message.hpp> |
| 12 | |
| 13 | BOOST_PRAGMA_MESSAGE("Skipping test because C++11 is not available") |
| 14 | int main() {} |
| 15 | |
| 16 | #else |
| 17 | |
| 18 | struct X1 {}; |
| 19 | BOOST_DESCRIBE_STRUCT(X1, (), ()) |
| 20 | |
| 21 | class X2 |
| 22 | { |
| 23 | BOOST_DESCRIBE_CLASS(X2, (), (), (), ()) |
| 24 | }; |
| 25 | |
| 26 | struct X3 {}; |
| 27 | class X4 {}; |
| 28 | union X5 {}; |
| 29 | |
| 30 | struct X6: X1 {}; |
| 31 | struct X7: X2 {}; |
| 32 | |
| 33 | int main() |
| 34 | { |
| 35 | using boost::describe::has_describe_members; |
| 36 | |
| 37 | #if defined(BOOST_DESCRIBE_CXX14) |
| 38 | |
| 39 | BOOST_TEST_TRAIT_TRUE((has_describe_members<X1>)); |
| 40 | BOOST_TEST_TRAIT_TRUE((has_describe_members<X2>)); |
| 41 | |
| 42 | #else |
| 43 | |
| 44 | BOOST_TEST_TRAIT_FALSE((has_describe_members<X1>)); |
| 45 | BOOST_TEST_TRAIT_FALSE((has_describe_members<X2>)); |
| 46 | |
| 47 | #endif |
| 48 | |
| 49 | BOOST_TEST_TRAIT_FALSE((has_describe_members<X3>)); |
| 50 | BOOST_TEST_TRAIT_FALSE((has_describe_members<X4>)); |
| 51 | BOOST_TEST_TRAIT_FALSE((has_describe_members<X5>)); |
| 52 | BOOST_TEST_TRAIT_FALSE((has_describe_members<X6>)); |
| 53 | BOOST_TEST_TRAIT_FALSE((has_describe_members<X7>)); |
| 54 | BOOST_TEST_TRAIT_FALSE((has_describe_members<int>)); |
| 55 | BOOST_TEST_TRAIT_FALSE((has_describe_members<void>)); |
| 56 | |
| 57 | return boost::report_errors(); |
| 58 | } |
| 59 | |
| 60 | #endif // !defined(BOOST_DESCRIBE_CXX11) |
| 61 |
