Back to home page

EIC code displayed by LXR

 
 

    


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 // Copyright 2020, 2021 Peter Dimov
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // https://www.boost.org/LICENSE_1_0.txt
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) // can never be instantiated - indirect virtual base class is inaccessible
0021 # pragma warning(disable: 4624) // destructor was implicitly defined as deleted
0022 #endif
0023 
0024 // is_public_base_of
0025 
0026 template<class T, class U> using is_public_base_of = std::is_convertible<U*, T*>;
0027 
0028 // is_protected_base_of
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 // is_virtual_base_of
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 // compute_base_modifiers
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 } // namespace detail
0070 } // namespace describe
0071 } // namespace boost
0072 
0073 #endif // #ifndef BOOST_DESCRIBE_DETAIL_COMPUTE_BASE_MODIFIERS_HPP_INCLUDED