select_arg_to_python_test.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright David Abrahams 2004. Distributed under the Boost
  2. // Software License, Version 1.0. (See accompanying
  3. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  4. #include <boost/python/converter/arg_to_python.hpp>
  5. #include <boost/python/type_id.hpp>
  6. #include <boost/python/handle.hpp>
  7. #include <boost/python/object.hpp>
  8. #include <iostream>
  9. // gcc 2.95.x and MIPSpro 7.3.1.3 linker seem to demand this definition
  10. #if ((defined(__GNUC__) && __GNUC__ < 3)) \
  11. || (defined(__sgi) && defined(__EDG_VERSION__) && (__EDG_VERSION__ == 238))
  12. namespace boost { namespace python {
  13. BOOST_PYTHON_DECL bool handle_exception_impl(function0<void>)
  14. {
  15. return true;
  16. }
  17. }}
  18. #endif
  19. int result;
  20. #define ASSERT_SAME(T1,T2) assert_same< T1,T2 >()
  21. template <class T, class U>
  22. void assert_same(U* = 0, T* = 0)
  23. {
  24. BOOST_STATIC_ASSERT((boost::is_same<T,U>::value));
  25. }
  26. int main()
  27. {
  28. using namespace boost::python::converter::detail;
  29. using namespace boost::python::converter;
  30. using namespace boost::python;
  31. using namespace boost;
  32. ASSERT_SAME(
  33. select_arg_to_python<int>::type, value_arg_to_python<int>
  34. );
  35. ASSERT_SAME(
  36. select_arg_to_python<reference_wrapper<int> >::type, reference_arg_to_python<int>
  37. );
  38. ASSERT_SAME(
  39. select_arg_to_python<pointer_wrapper<int> >::type, pointer_shallow_arg_to_python<int>
  40. );
  41. ASSERT_SAME(
  42. select_arg_to_python<int*>::type, pointer_deep_arg_to_python<int*>
  43. );
  44. ASSERT_SAME(
  45. select_arg_to_python<handle<> >::type, object_manager_arg_to_python<handle<> >
  46. );
  47. ASSERT_SAME(
  48. select_arg_to_python<object>::type, object_manager_arg_to_python<object>
  49. );
  50. ASSERT_SAME(
  51. select_arg_to_python<char[20]>::type, arg_to_python<char const*>
  52. );
  53. return result;
  54. }