00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00050 #ifndef RANGELIB_INCL_RANGELIB_HPP_OPERATOR_ADAPTORS
00051 #define RANGELIB_INCL_RANGELIB_HPP_OPERATOR_ADAPTORS
00052
00053 #ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00054 # define RANGELIB_VER_RANGELIB_HPP_OPERATOR_ADAPTORS_MAJOR 1
00055 # define RANGELIB_VER_RANGELIB_HPP_OPERATOR_ADAPTORS_MINOR 5
00056 # define RANGELIB_VER_RANGELIB_HPP_OPERATOR_ADAPTORS_REVISION 4
00057 # define RANGELIB_VER_RANGELIB_HPP_OPERATOR_ADAPTORS_EDIT 30
00058 #endif
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075 #ifndef RANGELIB_INCL_RANGELIB_HPP_RANGELIB
00076 # include <rangelib/rangelib.hpp>
00077 #endif
00078 #ifndef STLSOFT_INCL_STLSOFT_META_HPP_CAPABILITIES
00079 # include <stlsoft/meta/capabilities.hpp>
00080 #endif
00081 #ifndef STLSOFT_INCL_STLSOFT_META_HPP_SELECT_FIRST_TYPE_IF
00082 # include <stlsoft/meta/select_first_type_if.hpp>
00083 #endif
00084 #if defined(STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED)
00085 # ifndef STLSOFT_INCL_STLSOFT_META_HPP_MEMBER_TRAITS
00086 # include <stlsoft/meta/member_traits.hpp>
00087 # endif
00088 #endif
00089 #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_OPERATOR_BOOL
00090 # include <stlsoft/util/operator_bool.hpp>
00091 #endif
00092 #ifndef STLSOFT_INCL_STLSOFT_UTIL_HPP_INERT
00093 # include <stlsoft/util/inert.hpp>
00094 #endif
00095
00096
00097
00098
00099
00100 #ifndef RANGELIB_NO_NAMESPACE
00101 # if defined(_STLSOFT_NO_NAMESPACE) || \
00102 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00103
00104 namespace rangelib
00105 {
00106 # else
00107
00108
00109 namespace stlsoft
00110 {
00111
00112 namespace rangelib_project
00113 {
00114
00115 # endif
00116 #endif
00117
00118
00119
00120
00121
00127 template< ss_typename_param_k CR
00128 #if defined(STLSOFT_COMPILER_IS_MSVC) && \
00129 _MSC_VER < 1300
00130 , ss_typename_param_k R = inert
00131 #else
00132 , ss_typename_param_k R = void
00133 #endif
00134 >
00135 struct operator_adaptor_specific_traits
00136 {
00137 public:
00139 typedef CR const_reference;
00141 typedef R reference;
00142 };
00143
00144
00156 template< ss_typename_param_k R
00157 , ss_typename_param_k T
00158 >
00159 class mutating_operator_adaptor
00160 {
00161 public:
00163 typedef R adapted_range_type;
00165 typedef T traits_type;
00167 typedef mutating_operator_adaptor<R, T> class_type;
00169 typedef ss_typename_type_k traits_type::reference reference;
00171 typedef ss_typename_type_k traits_type::const_reference const_reference;
00172
00173 protected:
00178 mutating_operator_adaptor()
00179 {}
00180
00183 private:
00184 STLSOFT_DEFINE_OPERATOR_BOOL_TYPES_T(class_type, boolean_generator_type, boolean_type);
00185 public:
00187 operator boolean_type() const
00188 {
00189 return boolean_generator_type::translate(static_cast<adapted_range_type const*>(this)->is_open());
00190 }
00192 reference operator *()
00193 {
00194 return static_cast<adapted_range_type*>(this)->current();
00195 }
00197 const_reference operator *() const
00198 {
00199 return static_cast<adapted_range_type const*>(this)->current();
00200 }
00202 adapted_range_type& operator ++()
00203 {
00204 return static_cast<adapted_range_type*>(this)->advance();
00205 }
00208 adapted_range_type operator ++(int)
00209 {
00210 adapted_range_type ret(*static_cast<adapted_range_type const*>(this));
00211
00212 operator ++();
00213
00214 return ret;
00215 }
00217 };
00218
00230 template< ss_typename_param_k R
00231 , ss_typename_param_k T
00232 >
00233 class non_mutating_operator_adaptor
00234 {
00235 public:
00237 typedef R adapted_range_type;
00239 typedef T traits_type;
00241 typedef non_mutating_operator_adaptor<R, T> class_type;
00243 typedef ss_typename_type_k traits_type::const_reference const_reference;
00244
00245 protected:
00250 non_mutating_operator_adaptor()
00251 {}
00252
00255 private:
00256 STLSOFT_DEFINE_OPERATOR_BOOL_TYPES_T(class_type, boolean_generator_type, boolean_type);
00257 public:
00259 operator boolean_type() const
00260 {
00261 return boolean_generator_type::translate(static_cast<adapted_range_type const*>(this)->is_open());
00262 }
00264 const_reference operator *() const
00265 {
00266 return static_cast<adapted_range_type const*>(this)->current();
00267 }
00269 adapted_range_type& operator ++()
00270 {
00271 return static_cast<adapted_range_type*>(this)->advance();
00272 }
00275 adapted_range_type operator ++(int)
00276 {
00277 adapted_range_type ret(*static_cast<adapted_range_type const*>(this));
00278
00279 operator ++();
00280
00281 return ret;
00282 }
00284 };
00285
00286 #if defined(STLSOFT_CF_HAS_MEMBER_TYPE_SUPPORTED)
00287
00288 template< ss_typename_param_k R
00289 , ss_typename_param_k T
00290 , ss_bool_t
00291 >
00292 struct fixer_mutating_operator_adaptor
00293 {
00294 typedef mutating_operator_adaptor<R, T> type;
00295 };
00296
00297 # ifndef STLSOFT_DOCUMENTATION_SKIP_SECTION
00298
00299
00300 template< ss_typename_param_k R
00301 , ss_typename_param_k T
00302 >
00303 struct fixer_mutating_operator_adaptor<R, T, false>
00304 {
00305 typedef void type;
00306 };
00307
00308 # endif
00309
00315 template< ss_typename_param_k R
00316 , ss_typename_param_k T
00317 >
00318 struct operator_adaptor_selector
00319 {
00320 private:
00321 enum { HAS_MEMBER_ITERATOR = 0 != member_traits<R>::has_member_iterator };
00322
00323 public:
00325 typedef ss_typename_type_k select_first_type_if<ss_typename_type_k fixer_mutating_operator_adaptor<R, T, HAS_MEMBER_ITERATOR>::type
00326 , non_mutating_operator_adaptor<R, T>
00327 , HAS_MEMBER_ITERATOR
00328 >::type type;
00329 };
00330
00331 #endif
00332
00334
00335
00336 #ifdef STLSOFT_UNITTEST
00337 # include "./unittest/operator_adaptors_unittest_.h"
00338 #endif
00339
00340
00341
00342 #ifndef RANGELIB_NO_NAMESPACE
00343 # if defined(_STLSOFT_NO_NAMESPACE) || \
00344 defined(STLSOFT_DOCUMENTATION_SKIP_SECTION)
00345 }
00346 # else
00347 }
00348 }
00349 # endif
00350 #endif
00351
00352
00353
00354 #endif
00355
00356