Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:29:37

0001 // Boost.Bimap
0002 //
0003 // Copyright (c) 2006-2007 Matias Capeletto
0004 //
0005 // Distributed under the Boost Software License, Version 1.0.
0006 // (See accompanying file LICENSE_1_0.txt or copy at
0007 // http://www.boost.org/LICENSE_1_0.txt)
0008 
0009 /// \file container_adaptor/detail/identity_converters.hpp
0010 /// \brief Value and iterators identity converters.
0011 
0012 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
0013 #define BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
0014 
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 namespace boost {
0022 namespace bimaps {
0023 namespace container_adaptor {
0024 
0025 /// \brief Details of the container adaptor toolbox
0026 
0027 namespace detail {
0028 
0029 /// \brief Iterator identity converter used by default in container adaptors.
0030 /**
0031 If Iterator and ConstIterator are of the same type one of the convert function is not
0032 included.
0033                                                                                     **/
0034 
0035 template
0036 <
0037     class BaseIterator              , class Iterator,
0038     class BaseConstIterator         , class ConstIterator
0039 >
0040 struct iterator_to_base_identity
0041 {
0042     BaseIterator operator()(Iterator iter) const
0043     {
0044         return BaseIterator(iter);
0045     }
0046 
0047     BaseConstIterator operator()(ConstIterator iter) const
0048     {
0049         return BaseConstIterator(iter);
0050     }
0051 };
0052 
0053 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0054 
0055 template< class BaseIterator, class Iterator >
0056 struct iterator_to_base_identity<BaseIterator,Iterator,BaseIterator,Iterator>
0057 {
0058     BaseIterator operator()(Iterator iter) const
0059     {
0060         return BaseIterator(iter);
0061     }
0062 };
0063 
0064 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0065 
0066 /// \brief Iterator from base identity converter used by default in container adaptors.
0067 /**
0068 If Iterator and ConstIterator are of the same type one of the convert function is not
0069 included.
0070                                                                                     **/
0071 
0072 template
0073 <
0074     class BaseIterator              , class Iterator,
0075     class BaseConstIterator         , class ConstIterator
0076 >
0077 struct iterator_from_base_identity
0078 {
0079     Iterator operator()(BaseIterator iter) const
0080     {
0081         return Iterator(iter);
0082     }
0083     ConstIterator operator()(BaseConstIterator iter) const
0084     {
0085         return ConstIterator(iter);
0086     }
0087 };
0088 
0089 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0090 
0091 template< class BaseIterator, class Iterator, class ConstIterator >
0092 struct iterator_from_base_identity<BaseIterator,Iterator,BaseIterator,ConstIterator>
0093 {
0094     Iterator operator()(BaseIterator iter) const
0095     {
0096         return Iterator(iter);
0097     }
0098 };
0099 
0100 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0101 
0102 /// \brief Value to base identity converter used by default in container adaptors.
0103 
0104 template< class BaseValue, class Value >
0105 struct value_to_base_identity
0106 {
0107     BaseValue operator()(const Value & val) const
0108     {
0109         return BaseValue(val);
0110     }
0111 };
0112 
0113 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0114 
0115 template< class Value >
0116 struct value_to_base_identity< Value, Value >
0117 {
0118     const Value & operator()(const Value & val) const
0119     {
0120         return val;
0121     }
0122 };
0123 
0124 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0125 
0126 /// \brief Value from base identity converter used by default in container adaptors.
0127 
0128 template< class BaseValue, class Value >
0129 struct value_from_base_identity
0130 {
0131     Value operator()(const BaseValue & val) const
0132     {
0133         return Value(val);
0134     }
0135 };
0136 
0137 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0138 
0139 template< class Value >
0140 struct value_from_base_identity<Value,Value>
0141 {
0142     Value & operator()(Value & val) const
0143     {
0144         return val;
0145     }
0146 
0147     const Value & operator()(const Value & val) const
0148     {
0149         return val;
0150     }
0151 };
0152 
0153 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0154 
0155 /// \brief Key to base identity converter used by default in container adaptors.
0156 
0157 template< class BaseKey, class Key >
0158 struct key_to_base_identity
0159 {
0160     BaseKey operator()(const Key & k) const
0161     {
0162         return BaseKey(k);
0163     }
0164 };
0165 
0166 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0167 
0168 template< class Key >
0169 struct key_to_base_identity< Key, Key >
0170 {
0171     // As default accept any type as key in order to allow container
0172     // adaptors to work with compatible key types
0173 
0174     template< class CompatibleKey >
0175     const CompatibleKey & operator()(const CompatibleKey & k) const
0176     {
0177         return k;
0178     }
0179 };
0180 
0181 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0182 
0183 } // namespace detail
0184 } // namespace container_adaptor
0185 } // namespace bimaps
0186 } // namespace boost
0187 
0188 
0189 #endif // BOOST_BIMAP_CONTAINER_ADAPTOR_DETAIL_IDENTITY_CONVERTERS_HPP
0190 
0191