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 container_adaptor/detail/identity_converters.hpp
10 /// \brief Value and iterators identity converters.
12 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
13 #define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
15 #if defined(_MSC_VER) && (_MSC_VER>=1200)
19 #include <boost/config.hpp>
23 namespace container_adaptor
{
25 /// \brief Details of the container adaptor toolbox
29 /// \brief Iterator identity converter used by default in container adaptors.
31 If Iterator and ConstIterator are of the same type one of the convert function is not
37 class BaseIterator
, class Iterator
,
38 class BaseConstIterator
, class ConstIterator
40 struct iterator_to_base_identity
42 BaseIterator
operator()(Iterator iter
) const
44 return BaseIterator(iter
);
47 BaseConstIterator
operator()(ConstIterator iter
) const
49 return BaseConstIterator(iter
);
53 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
55 template< class BaseIterator
, class Iterator
>
56 struct iterator_to_base_identity
<BaseIterator
,Iterator
,BaseIterator
,Iterator
>
58 BaseIterator
operator()(Iterator iter
) const
60 return BaseIterator(iter
);
64 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
66 /// \brief Iterator from base identity converter used by default in container adaptors.
68 If Iterator and ConstIterator are of the same type one of the convert function is not
74 class BaseIterator
, class Iterator
,
75 class BaseConstIterator
, class ConstIterator
77 struct iterator_from_base_identity
79 Iterator
operator()(BaseIterator iter
) const
81 return Iterator(iter
);
83 ConstIterator
operator()(BaseConstIterator iter
) const
85 return ConstIterator(iter
);
89 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
91 template< class BaseIterator
, class Iterator
, class ConstIterator
>
92 struct iterator_from_base_identity
<BaseIterator
,Iterator
,BaseIterator
,ConstIterator
>
94 Iterator
operator()(BaseIterator iter
) const
96 return Iterator(iter
);
100 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
102 /// \brief Value to base identity converter used by default in container adaptors.
104 template< class BaseValue
, class Value
>
105 struct value_to_base_identity
107 BaseValue
operator()(const Value
& val
) const
109 return BaseValue(val
);
113 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
115 template< class Value
>
116 struct value_to_base_identity
< Value
, Value
>
118 const Value
& operator()(const Value
& val
) const
124 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
126 /// \brief Value from base identity converter used by default in container adaptors.
128 template< class BaseValue
, class Value
>
129 struct value_from_base_identity
131 Value
operator()(const BaseValue
& val
) const
137 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
139 template< class Value
>
140 struct value_from_base_identity
<Value
,Value
>
142 Value
& operator()(Value
& val
) const
147 const Value
& operator()(const Value
& val
) const
153 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
155 /// \brief Key to base identity converter used by default in container adaptors.
157 template< class BaseKey
, class Key
>
158 struct key_to_base_identity
160 BaseKey
operator()(const Key
& k
) const
166 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
168 template< class Key
>
169 struct key_to_base_identity
< Key
, Key
>
171 // As default accept any type as key in order to allow container
172 // adaptors to work with compatible key types
174 template< class CompatibleKey
>
175 const CompatibleKey
& operator()(const CompatibleKey
& k
) const
181 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
183 } // namespace detail
184 } // namespace container_adaptor
185 } // namespace bimaps
189 #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP