general.hpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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_DETAIL_GENERAL_DWA2006429_HPP
  5. # define BOOST_CONCEPT_DETAIL_GENERAL_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. // This implementation works on Comeau and GCC, all the way back to
  12. // 2.95
  13. namespace boost { namespace concept {
  14. template <class ModelFn>
  15. struct requirement_;
  16. namespace detail
  17. {
  18. template <void(*)()> struct instantiate {};
  19. }
  20. template <class Model>
  21. struct requirement
  22. {
  23. static void failed() { ((Model*)0)->~Model(); }
  24. };
  25. # ifdef BOOST_OLD_CONCEPT_SUPPORT
  26. template <class Model>
  27. struct constraint
  28. {
  29. static void failed() { ((Model*)0)->constraints(); }
  30. };
  31. template <class Model>
  32. struct requirement_<void(*)(Model)>
  33. : mpl::if_<
  34. concept::not_satisfied<Model>
  35. , constraint<Model>
  36. , requirement<Model>
  37. >::type
  38. {};
  39. # else
  40. // For GCC-2.x, these can't have exactly the same name
  41. template <class Model>
  42. struct requirement_<void(*)(Model)>
  43. : requirement<Model>
  44. {};
  45. # endif
  46. # define BOOST_CONCEPT_ASSERT_FN( ModelFnPtr ) \
  47. typedef ::boost::concept::detail::instantiate< \
  48. &::boost::concept::requirement_<ModelFnPtr>::failed> \
  49. BOOST_PP_CAT(boost_concept_check,__LINE__)
  50. }}
  51. #endif // BOOST_CONCEPT_DETAIL_GENERAL_DWA2006429_HPP