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