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 /// \file relation/detail/access_builder.hpp 10 /// \brief Define macros to help building metafunctions 11 12 #ifndef BOOST_BIMAP_RELATION_ACCESS_BUILDER_HPP 13 #define BOOST_BIMAP_RELATION_ACCESS_BUILDER_HPP 14 15 #if defined(_MSC_VER) 16 #pragma once 17 #endif 18 19 #include <boost/config.hpp> 20 21 #include <boost/bimap/relation/support/member_with_tag.hpp> 22 #include <boost/bimap/relation/member_at.hpp> 23 #include <boost/call_traits.hpp> 24 #include <boost/type_traits/is_const.hpp> 25 #include <boost/mpl/if.hpp> 26 #include <boost/mpl/not.hpp> 27 #include <boost/utility/enable_if.hpp> 28 29 30 /****************************************************************************** 31 BIMAP SYMMETRIC ACCESS RESULT OF 32 ******************************************************************************* 33 34 namespace result_of { 35 36 template< class Tag, class SymmetricType > 37 struct NAME 38 { 39 typedef -unspecified- type; 40 }; 41 42 } // namespace result_of 43 44 ******************************************************************************/ 45 46 /*===========================================================================*/ 47 #define BOOST_BIMAP_SYMMETRIC_ACCESS_RESULT_OF_BUILDER( \ 48 \ 49 NAME, \ 50 METAFUNCTION_BASE \ 51 ) \ 52 \ 53 namespace result_of { \ 54 \ 55 template< class Tag, class SymmetricType > \ 56 struct NAME \ 57 { \ 58 typedef BOOST_DEDUCED_TYPENAME METAFUNCTION_BASE \ 59 < \ 60 Tag,SymmetricType \ 61 \ 62 >::type value_type; \ 63 \ 64 typedef BOOST_DEDUCED_TYPENAME mpl::if_< is_const<SymmetricType>, \ 65 \ 66 BOOST_DEDUCED_TYPENAME call_traits<value_type>::const_reference, \ 67 \ 68 BOOST_DEDUCED_TYPENAME call_traits<value_type>::reference \ 69 \ 70 >::type type; \ 71 }; \ 72 \ 73 } 74 /*===========================================================================*/ 75 76 77 78 /****************************************************************************** 79 BIMAP SYMMETRIC ACCESS IMPLEMENTATION 80 ******************************************************************************* 81 82 namespace detail { 83 84 template< class Tag, class SymmetricType > 85 typename result_of::NAME<Tag,SymmetricType>::type 86 NAME( Tag , const Relation & ); 87 88 } // namespace detail 89 90 ******************************************************************************/ 91 92 93 /*===========================================================================*/ 94 #define BOOST_BIMAP_SYMMETRIC_ACCESS_IMPLEMENTATION_BUILDER( \ 95 \ 96 NAME, \ 97 TP_SYMMETRIC, \ 98 PARAMETER_NAME, \ 99 LEFT_BODY, \ 100 RIGHT_BODY \ 101 ) \ 102 \ 103 namespace detail { \ 104 \ 105 \ 106 \ 107 template< class TP_SYMMETRIC > \ 108 BOOST_DEDUCED_TYPENAME result_of::NAME \ 109 < \ 110 ::boost::bimaps::relation::member_at::left,TP_SYMMETRIC \ 111 \ 112 >::type \ 113 \ 114 NAME( ::boost::bimaps::relation::member_at::left, \ 115 TP_SYMMETRIC & PARAMETER_NAME ) \ 116 { \ 117 LEFT_BODY; \ 118 } \ 119 \ 120 template< class TP_SYMMETRIC > \ 121 BOOST_DEDUCED_TYPENAME result_of::NAME \ 122 < \ 123 ::boost::bimaps::relation::member_at::right,TP_SYMMETRIC \ 124 \ 125 >::type \ 126 \ 127 NAME( ::boost::bimaps::relation::member_at::right, \ 128 TP_SYMMETRIC & PARAMETER_NAME ) \ 129 { \ 130 RIGHT_BODY; \ 131 } \ 132 \ 133 } 134 /*===========================================================================*/ 135 136 137 /****************************************************************************** 138 BIMAP RELATION ACCESS INTERFACE 139 ******************************************************************************* 140 141 template< class Tag, class SymmetricType > 142 typename result_of::NAME<Tag,SymmetricType>::type 143 NAME( const SymmetricType & ); 144 145 ******************************************************************************/ 146 147 /*===========================================================================*/ 148 #define BOOST_BIMAP_SYMMETRIC_ACCESS_INTERFACE_BUILDER( \ 149 \ 150 NAME \ 151 ) \ 152 \ 153 template< class Tag, class SymmetricType > \ 154 BOOST_DEDUCED_TYPENAME result_of::NAME<Tag,SymmetricType>::type \ 155 NAME( SymmetricType & s ) \ 156 { \ 157 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support:: \ 158 member_with_tag \ 159 < \ 160 Tag,SymmetricType \ 161 \ 162 >::type member_at_tag; \ 163 \ 164 return detail::NAME(member_at_tag(),s); \ 165 } 166 /*===========================================================================*/ 167 168 169 #endif // BOOST_BIMAP_RELATION_ACCESS_BUILDER_HPP 170 171