msvc.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // Copyright David Abrahams 2006. 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. #ifndef BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP
  5. # define BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP
  6. # include <boost/preprocessor/cat.hpp>
  7. # include <boost/concept/detail/backward_compatibility.hpp>
  8. # include <boost/config.hpp>
  9. # ifdef BOOST_OLD_CONCEPT_SUPPORT
  10. # include <boost/concept/detail/has_constraints.hpp>
  11. # include <boost/type_traits/conditional.hpp>
  12. # endif
  13. # ifdef BOOST_MSVC
  14. # pragma warning(push)
  15. # pragma warning(disable:4100)
  16. # endif
  17. namespace boost { namespace concepts {
  18. template <class Model>
  19. struct check
  20. {
  21. virtual void failed(Model* x)
  22. {
  23. x->~Model();
  24. }
  25. };
  26. # ifndef BOOST_NO_PARTIAL_SPECIALIZATION
  27. struct failed {};
  28. template <class Model>
  29. struct check<failed ************ Model::************>
  30. {
  31. virtual void failed(Model* x)
  32. {
  33. x->~Model();
  34. }
  35. };
  36. # endif
  37. # ifdef BOOST_OLD_CONCEPT_SUPPORT
  38. namespace detail
  39. {
  40. // No need for a virtual function here, since evaluating
  41. // not_satisfied below will have already instantiated the
  42. // constraints() member.
  43. struct constraint {};
  44. }
  45. template <class Model>
  46. struct require
  47. : boost::conditional<
  48. not_satisfied<Model>::value
  49. , detail::constraint
  50. # ifndef BOOST_NO_PARTIAL_SPECIALIZATION
  51. , check<Model>
  52. # else
  53. , check<failed ************ Model::************>
  54. # endif
  55. >::type
  56. {};
  57. # else
  58. template <class Model>
  59. struct require
  60. # ifndef BOOST_NO_PARTIAL_SPECIALIZATION
  61. : check<Model>
  62. # else
  63. : check<failed ************ Model::************>
  64. # endif
  65. {};
  66. # endif
  67. # if BOOST_WORKAROUND(BOOST_MSVC, == 1310)
  68. //
  69. // The iterator library sees some really strange errors unless we
  70. // do things this way.
  71. //
  72. template <class Model>
  73. struct require<void(*)(Model)>
  74. {
  75. virtual void failed(Model*)
  76. {
  77. require<Model>();
  78. }
  79. };
  80. # define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
  81. enum \
  82. { \
  83. BOOST_PP_CAT(boost_concept_check,__LINE__) = \
  84. sizeof(::boost::concepts::require<ModelFnPtr>) \
  85. }
  86. # else // Not vc-7.1
  87. template <class Model>
  88. require<Model>
  89. require_(void(*)(Model));
  90. # define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
  91. enum \
  92. { \
  93. BOOST_PP_CAT(boost_concept_check,__LINE__) = \
  94. sizeof(::boost::concepts::require_((ModelFnPtr)0)) \
  95. }
  96. # endif
  97. }}
  98. # ifdef BOOST_MSVC
  99. # pragma warning(pop)
  100. # endif
  101. #endif // BOOST_CONCEPT_CHECK_MSVC_DWA2006429_HPP