File indexing completed on 2025-01-18 09:30:40
0001 #ifndef BOOST_DESCRIBE_DETAIL_COMPUTE_BASE_MODIFIERS_HPP_INCLUDED
0002 #define BOOST_DESCRIBE_DETAIL_COMPUTE_BASE_MODIFIERS_HPP_INCLUDED
0003
0004
0005
0006
0007
0008 #include <boost/describe/modifiers.hpp>
0009 #include <type_traits>
0010
0011 namespace boost
0012 {
0013 namespace describe
0014 {
0015 namespace detail
0016 {
0017
0018 #if defined(_MSC_VER)
0019 # pragma warning(push)
0020 # pragma warning(disable: 4594)
0021 # pragma warning(disable: 4624)
0022 #endif
0023
0024
0025
0026 template<class T, class U> using is_public_base_of = std::is_convertible<U*, T*>;
0027
0028
0029
0030 struct ipb_final
0031 {
0032 template<class T, class U> using fn = std::false_type;
0033 };
0034
0035 struct ipb_non_final
0036 {
0037 template<class T, class U> struct fn: U
0038 {
0039 static std::true_type f( T* );
0040
0041 template<class X> static auto g( X x ) -> decltype( f(x) );
0042 static std::false_type g( ... );
0043
0044 using type = decltype( g((U*)0) );
0045 };
0046 };
0047
0048 template<class T, class U> using is_protected_base_of =
0049 typename std::conditional<std::is_final<U>::value || std::is_union<U>::value, ipb_final, ipb_non_final>::type::template fn<T, U>::type;
0050
0051
0052
0053 template<class T, class U, class = void> struct can_cast: std::false_type {};
0054 template<class T, class U> struct can_cast<T, U, decltype((void)(U*)(T*)0)>: std::true_type {};
0055
0056 template<class T, class U> using is_virtual_base_of =
0057 std::integral_constant<bool, can_cast<U, T>::value && !can_cast<T, U>::value>;
0058
0059
0060 template<class C, class B> constexpr unsigned compute_base_modifiers() noexcept
0061 {
0062 return (is_public_base_of<B, C>::value? mod_public: (is_protected_base_of<B, C>::value? mod_protected: mod_private)) | (is_virtual_base_of<B, C>::value? mod_virtual: 0);
0063 }
0064
0065 #if defined(_MSC_VER)
0066 # pragma warning(pop)
0067 #endif
0068
0069 }
0070 }
0071 }
0072
0073 #endif