| 1 | #ifndef BOOST_DESCRIBE_BASES_HPP_INCLUDED |
|---|---|
| 2 | #define BOOST_DESCRIBE_BASES_HPP_INCLUDED |
| 3 | |
| 4 | // Copyright 2020, 2021 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/modifiers.hpp> |
| 9 | #include <boost/describe/detail/void_t.hpp> |
| 10 | #include <boost/describe/detail/config.hpp> |
| 11 | |
| 12 | #if defined(BOOST_DESCRIBE_CXX11) |
| 13 | |
| 14 | #include <boost/mp11/algorithm.hpp> |
| 15 | #include <type_traits> |
| 16 | |
| 17 | namespace boost |
| 18 | { |
| 19 | namespace describe |
| 20 | { |
| 21 | namespace detail |
| 22 | { |
| 23 | |
| 24 | template<class T> using _describe_bases = decltype( boost_base_descriptor_fn( static_cast<T**>(0) ) ); |
| 25 | |
| 26 | template<unsigned M> struct base_filter |
| 27 | { |
| 28 | template<class T> using fn = mp11::mp_bool< ( M & mod_any_access & T::modifiers ) != 0 >; |
| 29 | }; |
| 30 | |
| 31 | template<class T, class En = void> struct has_describe_bases: std::false_type |
| 32 | { |
| 33 | }; |
| 34 | |
| 35 | template<class T> struct has_describe_bases<T, void_t<_describe_bases<T>>>: std::true_type |
| 36 | { |
| 37 | }; |
| 38 | |
| 39 | } // namespace detail |
| 40 | |
| 41 | template<class T, unsigned M> using describe_bases = mp11::mp_copy_if_q<detail::_describe_bases<T>, detail::base_filter<M>>; |
| 42 | |
| 43 | template<class T> using has_describe_bases = detail::has_describe_bases<T>; |
| 44 | |
| 45 | } // namespace describe |
| 46 | } // namespace boost |
| 47 | |
| 48 | #endif // !defined(BOOST_DESCRIBE_CXX11) |
| 49 | |
| 50 | #endif // #ifndef BOOST_DESCRIBE_BASES_HPP_INCLUDED |
| 51 |
