#include //#include #include #include #include #include #include #include #include #include namespace py { namespace detail { struct bases_tag {}; } template< class B0 = void, class B1 = void, class B2 = void > struct bases : detail::bases_tag {}; /** @todo to be consistent w/ PARAM_NAME, these macros should generate _ClassType, etc with leading _ be default and in tag namespace by default */ BOOST_PARAMETER_TEMPLATE_KEYWORD(ClassType) BOOST_PARAMETER_TEMPLATE_KEYWORD(BaseList) BOOST_PARAMETER_TEMPLATE_KEYWORD(HeldType) BOOST_PARAMETER_TEMPLATE_KEYWORD(Copyable) template< typename Arg123X0 , typename Arg123X1 = boost::parameter::void_ , typename Arg123X2 = boost::parameter::void_ , typename Arg123X3 = boost::parameter::void_ , typename Args123 = typename boost::parameter::parameters< // IF(IS_EMPTY(DEFAULT(p)), required, optional) boost::parameter::required< tag::ClassType , boost::is_class > , boost::parameter::optional< // IF(IS_DEDUCED(p), deduced, tag::NAME(p)) boost::parameter::deduced // COMMA_IF(COMPL(IS_EMPTY(REQUIRES(p)))) REQUIRES(p) , boost::is_base_and_derived > , boost::parameter::optional< boost::parameter::deduced , boost::mpl::not_< boost::mpl::or_< boost::is_base_and_derived , boost::is_same > > > , boost::parameter::optional< boost::parameter::deduced , boost::is_same > >::bind::type , typename ClassType = typename boost::parameter::value_type< Args123, tag::ClassType >::type , typename BaseList = typename boost::parameter::value_type< // ... COMMA_IF(COMPL(IS_EMPTY(DEFAULT(p)))) DEFAULT(p) >::type Args123, tag::BaseList, bases<> >::type , typename HeldType = typename boost::parameter::value_type< Args123, tag::HeldType, ClassType >::type , typename Copyable = typename boost::parameter::value_type< Args123, tag::Copyable, void >::type > struct class_ /** @todo inherit from boost::python::class_ */ { typedef ClassType class_type; typedef BaseList base_list; typedef HeldType held_type; typedef Copyable copyable; }; } // namespace py INOUT(p) // [in | out | in out] TYPE(p) // [type] REQUIRES(p) // [unary_metafunc] DEFAULT(p) // [default_value] struct b { virtual ~b() = 0; }; struct d : b { ~d() {} }; // Named parameters. typedef py::class_< py::ClassType, py::Copyable > x1; /** @todo use std::auto_ptr instead of boost::shared_ptr */ typedef py::class_< d, py::HeldType< boost::shared_ptr >, py::BaseList< py::bases > > x2; // Deduced parameters. typedef py::class_< b, boost::noncopyable > y1; typedef py::class_< d, boost::shared_ptr, py::bases > y2; // Another benefit is that c1::ClassType is no longer allowed, the special typedef for class_type needs to be introduced (as usual) BOOST_MPL_ASSERT(( boost::is_same< x1::class_type, b > )); BOOST_MPL_ASSERT(( boost::is_same< x1::base_list, py::bases<> > )); BOOST_MPL_ASSERT(( boost::is_same< x1::held_type, b > )); BOOST_MPL_ASSERT(( boost::is_same< x1::copyable, boost::noncopyable > )); BOOST_MPL_ASSERT(( boost::is_same< x2::class_type, d > )); BOOST_MPL_ASSERT(( boost::is_same< x2::base_list, py::bases > )); BOOST_MPL_ASSERT(( boost::is_same< x2::held_type, boost::shared_ptr > )); BOOST_MPL_ASSERT(( boost::is_same< x2::copyable, void > )); BOOST_MPL_ASSERT(( boost::is_same< y1::class_type, b > )); BOOST_MPL_ASSERT(( boost::is_same< y1::base_list, py::bases<> > )); BOOST_MPL_ASSERT(( boost::is_same< y1::held_type, b > )); BOOST_MPL_ASSERT(( boost::is_same< y1::copyable, boost::noncopyable > )); BOOST_MPL_ASSERT(( boost::is_same< y2::class_type, d > )); BOOST_MPL_ASSERT(( boost::is_same< y2::base_list, py::bases > )); BOOST_MPL_ASSERT(( boost::is_same< y2::held_type, boost::shared_ptr > )); BOOST_MPL_ASSERT(( boost::is_same< y2::copyable, void > )); int main ( ) { return 0; }