Blame view

3rdparty/boost_1_81_0/boost/describe/detail/members.hpp 3.71 KB
63e88f80   Hu Chunming   提交三方库
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
  #ifndef BOOST_DESCRIBE_DETAIL_MEMBERS_HPP_INCLUDED
  #define BOOST_DESCRIBE_DETAIL_MEMBERS_HPP_INCLUDED
  
  // Copyright 2020 Peter Dimov
  // Distributed under the Boost Software License, Version 1.0.
  // https://www.boost.org/LICENSE_1_0.txt
  
  #include <boost/describe/modifiers.hpp>
  #include <boost/describe/detail/pp_for_each.hpp>
  #include <boost/describe/detail/pp_utilities.hpp>
  #include <boost/describe/detail/list.hpp>
  #include <type_traits>
  
  namespace boost
  {
  namespace describe
  {
  namespace detail
  {
  
  template<class Pm> constexpr unsigned add_static_modifier( Pm )
  {
      return std::is_member_pointer<Pm>::value? 0: mod_static;
  }
  
  template<class Pm> constexpr unsigned add_function_modifier( Pm )
  {
      return std::is_member_function_pointer<Pm>::value || std::is_function< std::remove_pointer_t<Pm> >::value? mod_function: 0;
  }
  
  template<class D, unsigned M> struct member_descriptor
  {
      static constexpr decltype(D::pointer()) pointer = D::pointer();
      static constexpr decltype(D::name()) name = D::name();
      static constexpr unsigned modifiers = M | add_static_modifier( D::pointer() ) | add_function_modifier( D::pointer() );
  };
  
  template<class D, unsigned M> constexpr decltype(D::pointer()) member_descriptor<D, M>::pointer;
  template<class D, unsigned M> constexpr decltype(D::name()) member_descriptor<D, M>::name;
  template<class D, unsigned M> constexpr unsigned member_descriptor<D, M>::modifiers;
  
  template<unsigned M, class... T> auto member_descriptor_fn_impl( int, T... )
  {
      return list<member_descriptor<T, M>...>();
  }
  
  template<class C, class F> constexpr auto mfn( F C::* p ) { return p; }
  template<class C, class F> constexpr auto mfn( F * p ) { return p; }
  
  #define BOOST_DESCRIBE_MEMBER_IMPL(C, m) , []{ struct _boost_desc { \
      static constexpr auto pointer() noexcept { return BOOST_DESCRIBE_PP_POINTER(C, m); } \
      static constexpr auto name() noexcept { return BOOST_DESCRIBE_PP_NAME(m); } }; return _boost_desc(); }()
  
  #if defined(_MSC_VER) && !defined(__clang__)
  
  #define BOOST_DESCRIBE_PUBLIC_MEMBERS(C, ...) inline auto boost_public_member_descriptor_fn( C** ) \
  { 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__) ); }
  
  #define BOOST_DESCRIBE_PROTECTED_MEMBERS(C, ...) inline auto boost_protected_member_descriptor_fn( C** ) \
  { 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__) ); }
  
  #define BOOST_DESCRIBE_PRIVATE_MEMBERS(C, ...) inline auto boost_private_member_descriptor_fn( C** ) \
  { 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__) ); }
  
  #else
  
  #define BOOST_DESCRIBE_PUBLIC_MEMBERS(C, ...) inline auto boost_public_member_descriptor_fn( C** ) \
  { 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__) ); }
  
  #define BOOST_DESCRIBE_PROTECTED_MEMBERS(C, ...) inline auto boost_protected_member_descriptor_fn( C** ) \
  { 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__) ); }
  
  #define BOOST_DESCRIBE_PRIVATE_MEMBERS(C, ...) inline auto boost_private_member_descriptor_fn( C** ) \
  { 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__) ); }
  
  #endif
  
  } // namespace detail
  } // namespace describe
  } // namespace boost
  
  #endif // #ifndef BOOST_DESCRIBE_DETAIL_MEMBERS_HPP_INCLUDED