bienstman4.cpp 813 B

123456789101112131415161718192021222324252627282930313233343536373839
  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. #include <boost/python/module.hpp>
  6. #include <boost/python/def.hpp>
  7. #include <boost/python/class.hpp>
  8. #include <boost/python/implicit.hpp>
  9. #include <boost/mpl/list.hpp>
  10. struct Type1 {};
  11. struct Term {Term(Type1 const&) {} };
  12. struct Expression {void add(Term const&) {} };
  13. BOOST_PYTHON_MODULE(bienstman4_ext)
  14. {
  15. using namespace boost::python;
  16. using boost::mpl::list;
  17. implicitly_convertible<Type1,Term>();
  18. class_<Expression>("Expression")
  19. .def("add", &Expression::add)
  20. ;
  21. class_<Type1>("T1")
  22. ;
  23. class_<Term>("Term", init<Type1&>())
  24. ;
  25. Type1 t1;
  26. Expression e;
  27. e.add(t1);
  28. }