msvc.hpp 2.5 KB

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