3 // Copyright (c) 2006-2007 Matias Capeletto
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)
9 /// \file relation/support/member_with_tag.hpp
10 /// \brief member_with_tag<tag,relation> metafunction
12 #ifndef BOOST_BIMAP_RELATION_SUPPORT_MEMBER_WITH_TAG_HPP
13 #define BOOST_BIMAP_RELATION_SUPPORT_MEMBER_WITH_TAG_HPP
15 #if defined(_MSC_VER) && (_MSC_VER>=1200)
19 #include <boost/config.hpp>
21 #include <boost/bimap/relation/member_at.hpp>
22 #include <boost/bimap/detail/debug/static_error.hpp>
23 #include <boost/utility/enable_if.hpp>
24 #include <boost/type_traits/is_same.hpp>
25 #include <boost/mpl/bool.hpp>
26 #include <boost/mpl/not.hpp>
27 #include <boost/mpl/and.hpp>
29 /** \struct boost::bimaps::relation::support::member_with_tag
31 \brief Metafunction to convert user tags to the member_at idiom.
35 template< class Tag, class Relation >
36 struct member_with_tag
38 typedef member_at::{side} type;
43 We have to allow that all the metafunctions that works with tags
44 and retrieves data from a Relation will work with member_at idiom
45 even if the type was tagged. This will be great for the user,
46 because he can choose to tag a member after he is using the
47 relation and the code will still work.
49 If we perform this check in every metafunction it will be very
50 tedious and error prone, so instead of that all metafunctions
51 that works with relations first call this metafunction that
52 convert the tag to a member_at tag.
54 See also member_at, is_tag_of_member_at_left, is_tag_of_member_at_right.
55 \ingroup relation_group
58 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
71 struct member_with_tag
73 BOOST_BIMAP_STATIC_ERROR( MEMBER_WITH_TAG_FAILURE, (Relation,Tag) );
76 template< class Relation >
77 struct member_with_tag
79 member_at::left, Relation, void
82 typedef member_at::left type;
85 template< class Relation >
86 struct member_with_tag
88 member_at::right, Relation, void
91 typedef member_at::right type;
94 template< class Relation >
95 struct member_with_tag
97 member_at::info, Relation, void
100 typedef member_at::info type;
104 template< class Tag, class Relation >
105 struct member_with_tag
108 BOOST_DEDUCED_TYPENAME enable_if
112 mpl::not_< is_same<Tag,member_at::left> >,
116 BOOST_DEDUCED_TYPENAME Relation::left_tag
123 typedef member_at::left type;
126 template< class Tag, class Relation >
127 struct member_with_tag
131 BOOST_DEDUCED_TYPENAME enable_if
135 mpl::not_< is_same<Tag,member_at::right> >,
139 BOOST_DEDUCED_TYPENAME Relation::right_tag
146 typedef member_at::right type;
149 template< class Tag, class Relation >
150 struct member_with_tag
153 BOOST_DEDUCED_TYPENAME enable_if
157 mpl::not_< is_same<Tag,member_at::info> >,
161 BOOST_DEDUCED_TYPENAME Relation::info_tag
168 typedef member_at::info type;
171 } // namespace support
172 } // namespace relation
173 } // namespace bimaps
176 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
178 #endif // BOOST_BIMAP_RELATION_SUPPORT_MEMBER_WITH_TAG_HPP