]> git.sesse.net Git - casparcg/blob - dependencies/boost/boost/bimap/container_adaptor/detail/identity_converters.hpp
Manually merged pull request #222
[casparcg] / dependencies / boost / boost / bimap / container_adaptor / detail / identity_converters.hpp
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 container_adaptor/detail/identity_converters.hpp
10 /// \brief Value and iterators identity converters.
11
12 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
13 #define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
14
15 #if defined(_MSC_VER) && (_MSC_VER>=1200)
16 #pragma once
17 #endif
18
19 #include <boost/config.hpp>
20
21 namespace boost {
22 namespace bimaps {
23 namespace container_adaptor {
24
25 /// \brief Details of the container adaptor toolbox
26
27 namespace detail {
28
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                                                                                     **/
34
35 template
36 <
37     class BaseIterator              , class Iterator,
38     class BaseConstIterator         , class ConstIterator
39 >
40 struct iterator_to_base_identity
41 {
42     BaseIterator operator()(Iterator iter) const
43     {
44         return BaseIterator(iter);
45     }
46
47     BaseConstIterator operator()(ConstIterator iter) const
48     {
49         return BaseConstIterator(iter);
50     }
51 };
52
53 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
54
55 template< class BaseIterator, class Iterator >
56 struct iterator_to_base_identity<BaseIterator,Iterator,BaseIterator,Iterator>
57 {
58     BaseIterator operator()(Iterator iter) const
59     {
60         return BaseIterator(iter);
61     }
62 };
63
64 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
65
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                                                                                     **/
71
72 template
73 <
74     class BaseIterator              , class Iterator,
75     class BaseConstIterator         , class ConstIterator
76 >
77 struct iterator_from_base_identity
78 {
79     Iterator operator()(BaseIterator iter) const
80     {
81         return Iterator(iter);
82     }
83     ConstIterator operator()(BaseConstIterator iter) const
84     {
85         return ConstIterator(iter);
86     }
87 };
88
89 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
90
91 template< class BaseIterator, class Iterator, class ConstIterator >
92 struct iterator_from_base_identity<BaseIterator,Iterator,BaseIterator,ConstIterator>
93 {
94     Iterator operator()(BaseIterator iter) const
95     {
96         return Iterator(iter);
97     }
98 };
99
100 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
101
102 /// \brief Value to base identity converter used by default in container adaptors.
103
104 template< class BaseValue, class Value >
105 struct value_to_base_identity
106 {
107     BaseValue operator()(const Value & val) const
108     {
109         return BaseValue(val);
110     }
111 };
112
113 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
114
115 template< class Value >
116 struct value_to_base_identity< Value, Value >
117 {
118     const Value & operator()(const Value & val) const
119     {
120         return val;
121     }
122 };
123
124 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
125
126 /// \brief Value from base identity converter used by default in container adaptors.
127
128 template< class BaseValue, class Value >
129 struct value_from_base_identity
130 {
131     Value operator()(const BaseValue & val) const
132     {
133         return Value(val);
134     }
135 };
136
137 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
138
139 template< class Value >
140 struct value_from_base_identity<Value,Value>
141 {
142     Value & operator()(Value & val) const
143     {
144         return val;
145     }
146
147     const Value & operator()(const Value & val) const
148     {
149         return val;
150     }
151 };
152
153 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
154
155 /// \brief Key to base identity converter used by default in container adaptors.
156
157 template< class BaseKey, class Key >
158 struct key_to_base_identity
159 {
160     BaseKey operator()(const Key & k) const
161     {
162         return BaseKey(k);
163     }
164 };
165
166 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
167
168 template< class Key >
169 struct key_to_base_identity< Key, Key >
170 {
171     // As default accept any type as key in order to allow container
172     // adaptors to work with compatible key types
173
174     template< class CompatibleKey >
175     const CompatibleKey & operator()(const CompatibleKey & k) const
176     {
177         return k;
178     }
179 };
180
181 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
182
183 } // namespace detail
184 } // namespace container_adaptor
185 } // namespace bimaps
186 } // namespace boost
187
188
189 #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
190
191