bases.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright David Abrahams 2002.
  2. // Distributed under the Boost Software License, Version 1.0. (See
  3. // accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #ifndef BASES_DWA2002321_HPP
  6. # define BASES_DWA2002321_HPP
  7. # include <boost/python/detail/prefix.hpp>
  8. # include <boost/python/detail/type_list.hpp>
  9. # include <boost/python/detail/type_traits.hpp>
  10. # include <boost/mpl/if.hpp>
  11. # include <boost/mpl/bool.hpp>
  12. # include <boost/preprocessor/enum_params_with_a_default.hpp>
  13. # include <boost/preprocessor/enum_params.hpp>
  14. namespace boost { namespace python {
  15. # define BOOST_PYTHON_BASE_PARAMS BOOST_PP_ENUM_PARAMS_Z(1, BOOST_PYTHON_MAX_BASES, Base)
  16. // A type list for specifying bases
  17. template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_BASES, typename Base, mpl::void_) >
  18. struct bases : detail::type_list< BOOST_PYTHON_BASE_PARAMS >::type
  19. {};
  20. namespace detail
  21. {
  22. template <class T> struct specifies_bases
  23. : mpl::false_
  24. {
  25. };
  26. template < BOOST_PP_ENUM_PARAMS_Z(1, BOOST_PYTHON_MAX_BASES, class Base) >
  27. struct specifies_bases< bases< BOOST_PYTHON_BASE_PARAMS > >
  28. : mpl::true_
  29. {
  30. };
  31. template <class T, class Prev = bases<> >
  32. struct select_bases
  33. : mpl::if_<
  34. specifies_bases<T>
  35. , T
  36. , Prev
  37. >
  38. {
  39. };
  40. }
  41. # undef BOOST_PYTHON_BASE_PARAMS
  42. }} // namespace boost::python
  43. #endif // BASES_DWA2002321_HPP