check_metadata.hpp 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Boost.Bimap
  2. //
  3. // Copyright (c) 2006-2007 Matias Capeletto
  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. #ifndef BOOST_BIMAP_DETAIL_CHECK_METADATA_HPP
  9. #define BOOST_BIMAP_DETAIL_CHECK_METADATA_HPP
  10. #if defined(_MSC_VER)
  11. #pragma once
  12. #endif
  13. #include <boost/config.hpp>
  14. #include <boost/mpl/assert.hpp>
  15. #include <boost/type_traits/is_same.hpp>
  16. #include <boost/preprocessor/cat.hpp>
  17. // Easier way to call BOOST_MPL_ASSERT_MSG in class scope
  18. /*===========================================================================*/
  19. #define BOOST_BIMAP_MPL_ASSERT_MSG_ACS(p1,p2,p3) \
  20. \
  21. struct p2 {}; \
  22. BOOST_MPL_ASSERT_MSG(p1,p2,p3); \
  23. /*===========================================================================*/
  24. // Build a descriptive name.
  25. /*===========================================================================*/
  26. #define BOOST_BIMAP_WRONG_METADATA_MESSAGE( \
  27. \
  28. P_CLASS, \
  29. P_NAME, \
  30. P_CORRECT_TYPE \
  31. \
  32. ) \
  33. \
  34. BOOST_PP_CAT \
  35. ( \
  36. WRONG_METADATA__, \
  37. BOOST_PP_CAT \
  38. ( \
  39. P_CLASS, \
  40. BOOST_PP_CAT \
  41. ( \
  42. __AT__, \
  43. BOOST_PP_CAT \
  44. ( \
  45. P_NAME, \
  46. BOOST_PP_CAT \
  47. ( \
  48. __IS_DIFERENT_TO__, \
  49. P_CORRECT_TYPE \
  50. ) \
  51. ) \
  52. ) \
  53. ) \
  54. )
  55. /*===========================================================================*/
  56. // Check if the metadata have the correct type, and if not inform
  57. // it with a useful compile time message.
  58. /*===========================================================================*/
  59. #define BOOST_BIMAP_CHECK_METADATA( \
  60. \
  61. P_CLASS, \
  62. P_NAME, \
  63. P_CORRECT_TYPE \
  64. \
  65. ) \
  66. \
  67. BOOST_BIMAP_MPL_ASSERT_MSG_ACS \
  68. ( \
  69. ( \
  70. ::boost::is_same \
  71. < \
  72. P_CLASS::P_NAME, \
  73. P_CORRECT_TYPE \
  74. \
  75. >::value \
  76. ), \
  77. BOOST_BIMAP_WRONG_METADATA_MESSAGE \
  78. ( \
  79. P_CLASS, \
  80. P_NAME, \
  81. P_CORRECT_TYPE \
  82. ), \
  83. (P_CLASS::P_NAME,P_CORRECT_TYPE) \
  84. )
  85. /*===========================================================================*/
  86. // Just for autodocumment the test code
  87. /*===========================================================================*/
  88. #define BOOST_BIMAP_TEST_STATIC_FUNCTION(NAME) \
  89. namespace NAME
  90. /*===========================================================================*/
  91. // Just for autodocument the test code
  92. /*===========================================================================*/
  93. #define BOOST_BIMAP_CALL_TEST_STATIC_FUNCTION(NAME)
  94. /*===========================================================================*/
  95. #endif // BOOST_BIMAP_DETAIL_CHECK_METADATA_HPP