bases.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef BOOST_DESCRIBE_BASES_HPP_INCLUDED
  2. #define BOOST_DESCRIBE_BASES_HPP_INCLUDED
  3. // Copyright 2020, 2021 Peter Dimov
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // https://www.boost.org/LICENSE_1_0.txt
  6. #include <boost/describe/modifiers.hpp>
  7. #include <boost/describe/detail/void_t.hpp>
  8. #include <boost/describe/detail/config.hpp>
  9. #if defined(BOOST_DESCRIBE_CXX11)
  10. #include <boost/mp11/algorithm.hpp>
  11. #include <type_traits>
  12. namespace boost
  13. {
  14. namespace describe
  15. {
  16. namespace detail
  17. {
  18. template<class T> using _describe_bases = decltype( boost_base_descriptor_fn( static_cast<T**>(0) ) );
  19. template<unsigned M> struct base_filter
  20. {
  21. template<class T> using fn = mp11::mp_bool< ( M & mod_any_access & T::modifiers ) != 0 >;
  22. };
  23. template<class T, class En = void> struct has_describe_bases: std::false_type
  24. {
  25. };
  26. template<class T> struct has_describe_bases<T, void_t<_describe_bases<T>>>: std::true_type
  27. {
  28. };
  29. } // namespace detail
  30. template<class T, unsigned M> using describe_bases = mp11::mp_copy_if_q<detail::_describe_bases<T>, detail::base_filter<M>>;
  31. template<class T> using has_describe_bases = detail::has_describe_bases<T>;
  32. } // namespace describe
  33. } // namespace boost
  34. #endif // !defined(BOOST_DESCRIBE_CXX11)
  35. #endif // #ifndef BOOST_DESCRIBE_BASES_HPP_INCLUDED