Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/boost_1_34_1/boost/python/bases.hpp @ 35

Last change on this file since 35 was 29, checked in by landauf, 16 years ago

updated boost from 1_33_1 to 1_34_1

File size: 2.1 KB
RevLine 
[29]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
8# include <boost/python/detail/prefix.hpp>
9# include <boost/type_traits/object_traits.hpp>
10# include <boost/python/detail/type_list.hpp>
11# include <boost/mpl/if.hpp>
12# include <boost/mpl/bool.hpp>
13# include <boost/preprocessor/enum_params_with_a_default.hpp>
14# include <boost/preprocessor/enum_params.hpp>
15
16namespace boost { namespace python { 
17
18# define BOOST_PYTHON_BASE_PARAMS BOOST_PP_ENUM_PARAMS_Z(1, BOOST_PYTHON_MAX_BASES, Base)
19
20  // A type list for specifying bases
21  template < BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(BOOST_PYTHON_MAX_BASES, typename Base, mpl::void_) >
22  struct bases : detail::type_list< BOOST_PYTHON_BASE_PARAMS >::type
23  {};
24
25  namespace detail
26  {
27# ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
28    template <class T> struct specifies_bases
29        : mpl::false_
30    {
31    };
32   
33    template < BOOST_PP_ENUM_PARAMS_Z(1, BOOST_PYTHON_MAX_BASES, class Base) >
34    struct specifies_bases< bases< BOOST_PYTHON_BASE_PARAMS > >
35        : mpl::true_
36    {
37    };
38# else
39    template < BOOST_PP_ENUM_PARAMS(BOOST_PYTHON_MAX_BASES, class Base) >
40    static char is_bases_helper(bases< BOOST_PYTHON_BASE_PARAMS > const&);
41   
42    static char (& is_bases_helper(...) )[256];
43
44    template <class T>
45    struct specifies_bases
46    {
47     private:
48        static typename add_reference<T>::type make();
49        BOOST_STATIC_CONSTANT(bool, non_ref = !is_reference<T>::value);
50     public:
51        BOOST_STATIC_CONSTANT(bool, value = non_ref & (sizeof(is_bases_helper(make())) == 1));
52        typedef mpl::bool_<value> type;
53    };
54# endif
55    template <class T, class Prev = bases<> >
56    struct select_bases
57        : mpl::if_<
58                specifies_bases<T>
59                , T
60                , Prev
61          >
62    {
63    };
64  }
65# undef BOOST_PYTHON_BASE_PARAMS
66}} // namespace boost::python
67
68#endif // BASES_DWA2002321_HPP
Note: See TracBrowser for help on using the repository browser.