fix doc example typo
[boost.git] / boost / bimap / container_adaptor / detail / identity_converters.hpp
blobf6f5864122f242f737b29aaa2ed09f6de58a947b
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)
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)
16 #pragma once
17 #endif
19 #include <boost/config.hpp>
21 namespace boost {
22 namespace bimaps {
23 namespace container_adaptor {
25 /// \brief Details of the container adaptor toolbox
27 namespace detail {
29 /// \brief Iterator identity converter used by default in container adaptors.
30 /**
31 If Iterator and ConstIterator are of the same type one of the convert function is not
32 included.
33 **/
35 template
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.
67 /**
68 If Iterator and ConstIterator are of the same type one of the convert function is not
69 included.
70 **/
72 template
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
120 return val;
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
133 return Value(val);
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
144 return val;
147 const Value & operator()(const Value & val) const
149 return val;
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
162 return BaseKey(k);
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
177 return k;
181 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
183 } // namespace detail
184 } // namespace container_adaptor
185 } // namespace bimaps
186 } // namespace boost
189 #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP