msvc.hpp 2.0 KB

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