sp_convertible.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
  2. #define BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED
  3. // MS compatible compilers support #pragma once
  4. #if defined(_MSC_VER) && (_MSC_VER >= 1020)
  5. # pragma once
  6. #endif
  7. // detail/sp_convertible.hpp
  8. //
  9. // Copyright 2008 Peter Dimov
  10. //
  11. // Distributed under the Boost Software License, Version 1.0.
  12. // See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt
  14. #include <boost/config.hpp>
  15. #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( BOOST_NO_SFINAE )
  16. # define BOOST_SP_NO_SP_CONVERTIBLE
  17. #endif
  18. #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __GNUC__ ) && ( __GNUC__ * 100 + __GNUC_MINOR__ < 303 )
  19. # define BOOST_SP_NO_SP_CONVERTIBLE
  20. #endif
  21. #if !defined( BOOST_SP_NO_SP_CONVERTIBLE ) && defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x610 )
  22. # define BOOST_SP_NO_SP_CONVERTIBLE
  23. #endif
  24. #if !defined( BOOST_SP_NO_SP_CONVERTIBLE )
  25. namespace boost
  26. {
  27. namespace detail
  28. {
  29. template< class Y, class T > struct sp_convertible
  30. {
  31. typedef char (&yes) [1];
  32. typedef char (&no) [2];
  33. static yes f( T* );
  34. static no f( ... );
  35. enum _vt { value = sizeof( f( static_cast<Y*>(0) ) ) == sizeof(yes) };
  36. };
  37. struct sp_empty
  38. {
  39. };
  40. template< bool > struct sp_enable_if_convertible_impl;
  41. template<> struct sp_enable_if_convertible_impl<true>
  42. {
  43. typedef sp_empty type;
  44. };
  45. template<> struct sp_enable_if_convertible_impl<false>
  46. {
  47. };
  48. template< class Y, class T > struct sp_enable_if_convertible: public sp_enable_if_convertible_impl< sp_convertible< Y, T >::value >
  49. {
  50. };
  51. } // namespace detail
  52. } // namespace boost
  53. #endif // !defined( BOOST_SP_NO_SP_CONVERTIBLE )
  54. #endif // #ifndef BOOST_SMART_PTR_DETAIL_SP_CONVERTIBLE_HPP_INCLUDED