convertible.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 CONVERTIBLE_DWA2002614_HPP
  6. # define CONVERTIBLE_DWA2002614_HPP
  7. # if defined(__EDG_VERSION__) && __EDG_VERSION__ <= 241
  8. # include <boost/mpl/if.hpp>
  9. # include <boost/python/detail/type_traits.hpp>
  10. # endif
  11. // Supplies a runtime is_convertible check which can be used with tag
  12. // dispatching to work around the Metrowerks Pro7 limitation with boost/std::is_convertible
  13. namespace boost { namespace python { namespace detail {
  14. typedef char* yes_convertible;
  15. typedef int* no_convertible;
  16. template <class Target>
  17. struct convertible
  18. {
  19. # if !defined(__EDG_VERSION__) || __EDG_VERSION__ > 241 || __EDG_VERSION__ == 238
  20. static inline no_convertible check(...) { return 0; }
  21. static inline yes_convertible check(Target) { return 0; }
  22. # else
  23. template <class X>
  24. static inline typename mpl::if_c<
  25. is_convertible<X,Target>::value
  26. , yes_convertible
  27. , no_convertible
  28. >::type check(X const&) { return 0; }
  29. # endif
  30. };
  31. }}} // namespace boost::python::detail
  32. #endif // CONVERTIBLE_DWA2002614_HPP