File indexing completed on 2025-01-18 09:30:40
0001 #ifndef BOOST_DESCRIBE_DETAIL_MEMBERS_HPP_INCLUDED
0002 #define BOOST_DESCRIBE_DETAIL_MEMBERS_HPP_INCLUDED
0003
0004
0005
0006
0007
0008 #include <boost/describe/modifiers.hpp>
0009 #include <boost/describe/detail/pp_for_each.hpp>
0010 #include <boost/describe/detail/pp_utilities.hpp>
0011 #include <boost/describe/detail/list.hpp>
0012 #include <type_traits>
0013
0014 namespace boost
0015 {
0016 namespace describe
0017 {
0018 namespace detail
0019 {
0020
0021 template<class Pm> constexpr unsigned add_static_modifier( Pm )
0022 {
0023 return std::is_member_pointer<Pm>::value? 0: mod_static;
0024 }
0025
0026 template<class Pm> constexpr unsigned add_function_modifier( Pm )
0027 {
0028 return std::is_member_function_pointer<Pm>::value || std::is_function< std::remove_pointer_t<Pm> >::value? mod_function: 0;
0029 }
0030
0031 template<class D, unsigned M> struct member_descriptor
0032 {
0033 static constexpr decltype(D::pointer()) pointer = D::pointer();
0034 static constexpr decltype(D::name()) name = D::name();
0035 static constexpr unsigned modifiers = M | add_static_modifier( D::pointer() ) | add_function_modifier( D::pointer() );
0036 };
0037
0038 #ifndef __cpp_inline_variables
0039 template<class D, unsigned M> constexpr decltype(D::pointer()) member_descriptor<D, M>::pointer;
0040 template<class D, unsigned M> constexpr decltype(D::name()) member_descriptor<D, M>::name;
0041 template<class D, unsigned M> constexpr unsigned member_descriptor<D, M>::modifiers;
0042 #endif
0043
0044 template<unsigned M, class... T> auto member_descriptor_fn_impl( int, T... )
0045 {
0046 return list<member_descriptor<T, M>...>();
0047 }
0048
0049 template<class C, class F> constexpr auto mfn( F C::* p ) { return p; }
0050 template<class C, class F> constexpr auto mfn( F * p ) { return p; }
0051
0052 #define BOOST_DESCRIBE_MEMBER_IMPL(C, m) , []{ struct _boost_desc { \
0053 static constexpr auto pointer() noexcept { return BOOST_DESCRIBE_PP_POINTER(C, m); } \
0054 static constexpr auto name() noexcept { return BOOST_DESCRIBE_PP_NAME(m); } }; return _boost_desc(); }()
0055
0056 #if defined(_MSC_VER) && !defined(__clang__)
0057
0058 #define BOOST_DESCRIBE_PUBLIC_MEMBERS(C, ...) inline auto boost_public_member_descriptor_fn( C** ) \
0059 { return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_public>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, __VA_ARGS__) ); }
0060
0061 #define BOOST_DESCRIBE_PROTECTED_MEMBERS(C, ...) inline auto boost_protected_member_descriptor_fn( C** ) \
0062 { return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_protected>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, __VA_ARGS__) ); }
0063
0064 #define BOOST_DESCRIBE_PRIVATE_MEMBERS(C, ...) inline auto boost_private_member_descriptor_fn( C** ) \
0065 { return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_private>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, __VA_ARGS__) ); }
0066
0067 #else
0068
0069 #define BOOST_DESCRIBE_PUBLIC_MEMBERS(C, ...) inline auto boost_public_member_descriptor_fn( C** ) \
0070 { return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_public>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, ##__VA_ARGS__) ); }
0071
0072 #define BOOST_DESCRIBE_PROTECTED_MEMBERS(C, ...) inline auto boost_protected_member_descriptor_fn( C** ) \
0073 { return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_protected>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, ##__VA_ARGS__) ); }
0074
0075 #define BOOST_DESCRIBE_PRIVATE_MEMBERS(C, ...) inline auto boost_private_member_descriptor_fn( C** ) \
0076 { return boost::describe::detail::member_descriptor_fn_impl<boost::describe::mod_private>( 0 BOOST_DESCRIBE_PP_FOR_EACH(BOOST_DESCRIBE_MEMBER_IMPL, C, ##__VA_ARGS__) ); }
0077
0078 #endif
0079
0080 }
0081 }
0082 }
0083
0084 #endif