| 1 | #ifndef BOOST_DESCRIBE_CLASS_HPP_INCLUDED |
| 2 | #define BOOST_DESCRIBE_CLASS_HPP_INCLUDED |
| 3 | |
| 4 | // Copyright 2020 Peter Dimov |
| 5 | // Distributed under the Boost Software License, Version 1.0. |
| 6 | // https://www.boost.org/LICENSE_1_0.txt |
| 7 | |
| 8 | #include <boost/describe/detail/config.hpp> |
| 9 | |
| 10 | #if !defined(BOOST_DESCRIBE_CXX14) |
| 11 | |
| 12 | #define BOOST_DESCRIBE_CLASS(C, Bases, Public, Protected, Private) |
| 13 | #define BOOST_DESCRIBE_STRUCT(C, Bases, Members) |
| 14 | |
| 15 | #else |
| 16 | |
| 17 | #include <boost/describe/detail/bases.hpp> |
| 18 | #include <boost/describe/detail/members.hpp> |
| 19 | #include <type_traits> |
| 20 | |
| 21 | namespace boost |
| 22 | { |
| 23 | namespace describe |
| 24 | { |
| 25 | |
| 26 | #if defined(_MSC_VER) && !defined(__clang__) |
| 27 | |
| 28 | #define BOOST_DESCRIBE_PP_UNPACK(...) __VA_ARGS__ |
| 29 | |
| 30 | #define BOOST_DESCRIBE_CLASS(C, Bases, Public, Protected, Private) \ |
| 31 | friend BOOST_DESCRIBE_BASES(C, BOOST_DESCRIBE_PP_UNPACK Bases) \ |
| 32 | friend BOOST_DESCRIBE_PUBLIC_MEMBERS(C, BOOST_DESCRIBE_PP_UNPACK Public) \ |
| 33 | friend BOOST_DESCRIBE_PROTECTED_MEMBERS(C, BOOST_DESCRIBE_PP_UNPACK Protected) \ |
| 34 | friend BOOST_DESCRIBE_PRIVATE_MEMBERS(C, BOOST_DESCRIBE_PP_UNPACK Private) |
| 35 | |
| 36 | #define BOOST_DESCRIBE_STRUCT(C, Bases, Members) \ |
| 37 | static_assert(std::is_class<C>::value || std::is_union<C>::value, "BOOST_DESCRIBE_STRUCT should only be used with class types"); \ |
| 38 | BOOST_DESCRIBE_BASES(C, BOOST_DESCRIBE_PP_UNPACK Bases) \ |
| 39 | BOOST_DESCRIBE_PUBLIC_MEMBERS(C, BOOST_DESCRIBE_PP_UNPACK Members) \ |
| 40 | BOOST_DESCRIBE_PROTECTED_MEMBERS(C) \ |
| 41 | BOOST_DESCRIBE_PRIVATE_MEMBERS(C) |
| 42 | |
| 43 | #else |
| 44 | |
| 45 | #if defined(__GNUC__) && __GNUC__ >= 8 |
| 46 | # define BOOST_DESCRIBE_PP_UNPACK(...) __VA_OPT__(,) __VA_ARGS__ |
| 47 | #else |
| 48 | # define BOOST_DESCRIBE_PP_UNPACK(...) , ##__VA_ARGS__ |
| 49 | #endif |
| 50 | |
| 51 | #define BOOST_DESCRIBE_BASES_(...) BOOST_DESCRIBE_BASES(__VA_ARGS__) |
| 52 | #define BOOST_DESCRIBE_PUBLIC_MEMBERS_(...) BOOST_DESCRIBE_PUBLIC_MEMBERS(__VA_ARGS__) |
| 53 | #define BOOST_DESCRIBE_PROTECTED_MEMBERS_(...) BOOST_DESCRIBE_PROTECTED_MEMBERS(__VA_ARGS__) |
| 54 | #define BOOST_DESCRIBE_PRIVATE_MEMBERS_(...) BOOST_DESCRIBE_PRIVATE_MEMBERS(__VA_ARGS__) |
| 55 | |
| 56 | #define BOOST_DESCRIBE_CLASS(C, Bases, Public, Protected, Private) \ |
| 57 | BOOST_DESCRIBE_MAYBE_UNUSED friend BOOST_DESCRIBE_BASES_(C BOOST_DESCRIBE_PP_UNPACK Bases) \ |
| 58 | BOOST_DESCRIBE_MAYBE_UNUSED friend BOOST_DESCRIBE_PUBLIC_MEMBERS_(C BOOST_DESCRIBE_PP_UNPACK Public) \ |
| 59 | BOOST_DESCRIBE_MAYBE_UNUSED friend BOOST_DESCRIBE_PROTECTED_MEMBERS_(C BOOST_DESCRIBE_PP_UNPACK Protected) \ |
| 60 | BOOST_DESCRIBE_MAYBE_UNUSED friend BOOST_DESCRIBE_PRIVATE_MEMBERS_(C BOOST_DESCRIBE_PP_UNPACK Private) |
| 61 | |
| 62 | #define BOOST_DESCRIBE_STRUCT(C, Bases, Members) \ |
| 63 | static_assert(std::is_class<C>::value || std::is_union<C>::value, "BOOST_DESCRIBE_STRUCT should only be used with class types"); \ |
| 64 | BOOST_DESCRIBE_MAYBE_UNUSED BOOST_DESCRIBE_BASES_(C BOOST_DESCRIBE_PP_UNPACK Bases) \ |
| 65 | BOOST_DESCRIBE_MAYBE_UNUSED BOOST_DESCRIBE_PUBLIC_MEMBERS_(C BOOST_DESCRIBE_PP_UNPACK Members) \ |
| 66 | BOOST_DESCRIBE_MAYBE_UNUSED BOOST_DESCRIBE_PROTECTED_MEMBERS_(C) \ |
| 67 | BOOST_DESCRIBE_MAYBE_UNUSED BOOST_DESCRIBE_PRIVATE_MEMBERS_(C) |
| 68 | |
| 69 | #endif |
| 70 | |
| 71 | } // namespace describe |
| 72 | } // namespace boost |
| 73 | |
| 74 | #endif // !defined(BOOST_DESCRIBE_CXX14) |
| 75 | |
| 76 | #endif // #ifndef BOOST_DESCRIBE_CLASS_HPP_INCLUDED |
| 77 | |