|
| 1 | +// Copyright David Abrahams 2002. Permission to copy, use, |
| 2 | +// modify, sell and distribute this software is granted provided this |
| 3 | +// copyright notice appears in all copies. This software is provided |
| 4 | +// "as is" without express or implied warranty, and with no claim as |
| 5 | +// to its suitability for any purpose. |
| 6 | +#include <boost/python/bases.hpp> |
| 7 | +#include <boost/static_assert.hpp> |
| 8 | +#include <boost/type_traits/same_traits.hpp> |
| 9 | + |
| 10 | +struct A; |
| 11 | +struct B; |
| 12 | + |
| 13 | +template <class X, class Y, class Z> |
| 14 | +struct choose_bases |
| 15 | + : boost::python::detail::select_bases< |
| 16 | + X |
| 17 | + , typename boost::python::detail::select_bases< |
| 18 | + Y |
| 19 | + , typename boost::python::detail::select_bases<Z>::type |
| 20 | + >::type> |
| 21 | +{ |
| 22 | + |
| 23 | +}; |
| 24 | + |
| 25 | +int main() |
| 26 | +{ |
| 27 | + BOOST_STATIC_ASSERT((boost::python::detail::specifies_bases< |
| 28 | + boost::python::bases<A,B> >::value)); |
| 29 | + |
| 30 | + BOOST_STATIC_ASSERT((!boost::python::detail::specifies_bases< |
| 31 | + boost::python::bases<A,B>& >::value)); |
| 32 | + |
| 33 | + BOOST_STATIC_ASSERT((!boost::python::detail::specifies_bases< |
| 34 | + void* >::value)); |
| 35 | + |
| 36 | + BOOST_STATIC_ASSERT((!boost::python::detail::specifies_bases< |
| 37 | + int >::value)); |
| 38 | + |
| 39 | + BOOST_STATIC_ASSERT((!boost::python::detail::specifies_bases< |
| 40 | + int[5] >::value)); |
| 41 | + |
| 42 | + typedef boost::python::detail::select_bases< |
| 43 | + int |
| 44 | + , boost::python::detail::select_bases<char*>::type > collected1; |
| 45 | + |
| 46 | + BOOST_STATIC_ASSERT((boost::is_same<collected1::type,boost::python::bases<> >::value)); |
| 47 | + BOOST_STATIC_ASSERT((boost::is_same<choose_bases<int,char*,long>::type,boost::python::bases<> >::value)); |
| 48 | + |
| 49 | + typedef boost::python::detail::select_bases< |
| 50 | + int |
| 51 | + , boost::python::detail::select_bases< |
| 52 | + boost::python::bases<A,B> |
| 53 | + , boost::python::detail::select_bases< |
| 54 | + A |
| 55 | + >::type |
| 56 | + >::type |
| 57 | + > collected2; |
| 58 | + |
| 59 | + BOOST_STATIC_ASSERT((boost::is_same<collected2::type,boost::python::bases<A,B> >::value)); |
| 60 | + BOOST_STATIC_ASSERT((boost::is_same<choose_bases<int,boost::python::bases<A,B>,long>::type,boost::python::bases<A,B> >::value)); |
| 61 | + |
| 62 | + return 0; |
| 63 | +} |
0 commit comments