has_rebind.hpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #ifndef BOOST_MPL_AUX_HAS_REBIND_HPP_INCLUDED
  2. #define BOOST_MPL_AUX_HAS_REBIND_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2002-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #include <boost/mpl/aux_/config/msvc.hpp>
  14. #include <boost/mpl/aux_/config/intel.hpp>
  15. #include <boost/mpl/aux_/config/workaround.hpp>
  16. #if BOOST_WORKAROUND(__EDG_VERSION__, <= 244) && !defined(BOOST_INTEL_CXX_VERSION)
  17. # include <boost/mpl/has_xxx.hpp>
  18. #elif BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  19. # include <boost/mpl/has_xxx.hpp>
  20. # include <boost/mpl/if.hpp>
  21. # include <boost/mpl/bool.hpp>
  22. # include <boost/mpl/aux_/msvc_is_class.hpp>
  23. #elif BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610))
  24. # include <boost/mpl/if.hpp>
  25. # include <boost/mpl/bool.hpp>
  26. # include <boost/mpl/aux_/yes_no.hpp>
  27. # include <boost/mpl/aux_/config/static_constant.hpp>
  28. # include <boost/type_traits/is_class.hpp>
  29. #else
  30. # include <boost/mpl/aux_/type_wrapper.hpp>
  31. # include <boost/mpl/aux_/yes_no.hpp>
  32. # include <boost/mpl/aux_/config/static_constant.hpp>
  33. #endif
  34. namespace boost { namespace mpl { namespace aux {
  35. #if BOOST_WORKAROUND(__EDG_VERSION__, <= 244) && !defined(BOOST_INTEL_CXX_VERSION)
  36. BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_rebind, rebind, false)
  37. #elif BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  38. BOOST_MPL_HAS_XXX_TRAIT_NAMED_DEF(has_rebind_impl, rebind, false)
  39. template< typename T >
  40. struct has_rebind
  41. : if_<
  42. msvc_is_class<T>
  43. , has_rebind_impl<T>
  44. , bool_<false>
  45. >::type
  46. {
  47. };
  48. #else // the rest
  49. template< typename T > struct has_rebind_tag {};
  50. no_tag operator|(has_rebind_tag<int>, void const volatile*);
  51. # if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x610))
  52. template< typename T >
  53. struct has_rebind
  54. {
  55. static has_rebind_tag<T>* get();
  56. BOOST_STATIC_CONSTANT(bool, value =
  57. sizeof(has_rebind_tag<int>() | get()) == sizeof(yes_tag)
  58. );
  59. };
  60. # else // BOOST_BORLANDC
  61. template< typename T >
  62. struct has_rebind_impl
  63. {
  64. static T* get();
  65. BOOST_STATIC_CONSTANT(bool, value =
  66. sizeof(has_rebind_tag<int>() | get()) == sizeof(yes_tag)
  67. );
  68. };
  69. template< typename T >
  70. struct has_rebind
  71. : if_<
  72. is_class<T>
  73. , has_rebind_impl<T>
  74. , bool_<false>
  75. >::type
  76. {
  77. };
  78. # endif // BOOST_BORLANDC
  79. #endif
  80. }}}
  81. #endif // BOOST_MPL_AUX_HAS_REBIND_HPP_INCLUDED