Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 08:05:58

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