Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:24:23

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 detail/set_view_iterator.hpp
0010 /// \brief Iterator adaptors from multi-index to bimap.
0011 
0012 #ifndef BOOST_BIMAP_DETAIL_SET_VIEW_ITERATOR_HPP
0013 #define BOOST_BIMAP_DETAIL_SET_VIEW_ITERATOR_HPP
0014 
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018 
0019 #include <boost/config.hpp>
0020 
0021 // Boost
0022 
0023 #ifndef BOOST_BIMAP_DISABLE_SERIALIZATION 
0024   #include <boost/core/serialization.hpp>
0025 #endif // BOOST_BIMAP_DISABLE_SERIALIZATION
0026 
0027 #include <boost/iterator/iterator_adaptor.hpp>
0028 #include <boost/bimap/relation/support/get_pair_functor.hpp>
0029 
0030 namespace boost {
0031 namespace bimaps {
0032 namespace detail {
0033 
0034 
0035 /** \brief Set View Iterator adaptor from multi index to bimap.
0036 
0037 This is class is based on transform iterator from Boost.Iterator that is
0038 modified to allow serialization. It has been specialized for this
0039 library, and EBO optimization was applied to the functor.
0040 
0041                                                                       **/
0042 
0043 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0044 
0045 template< class CoreIterator > struct set_view_iterator;
0046 
0047 template< class CoreIterator >
0048 struct set_view_iterator_base
0049 {
0050     typedef iterator_adaptor
0051     <
0052         set_view_iterator< CoreIterator >,
0053         CoreIterator,
0054         BOOST_DEDUCED_TYPENAME CoreIterator::value_type::above_view
0055 
0056     > type;
0057 };
0058 
0059 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0060 
0061 template< class CoreIterator >
0062 struct set_view_iterator : public set_view_iterator_base<CoreIterator>::type
0063 {
0064     typedef BOOST_DEDUCED_TYPENAME set_view_iterator_base<CoreIterator>::type base_;
0065 
0066     public:
0067 
0068     set_view_iterator() {}
0069 
0070     set_view_iterator(CoreIterator const& iter)
0071       : base_(iter) {}
0072 
0073     set_view_iterator(set_view_iterator const & iter)
0074       : base_(iter.base()) {}
0075 
0076     typename base_::reference dereference() const
0077     {
0078         return const_cast<
0079             BOOST_DEDUCED_TYPENAME base_::base_type::value_type*>(
0080                 &(*this->base())
0081             )->get_view();
0082     }
0083 
0084     private:
0085 
0086     friend class boost::iterators::iterator_core_access;
0087 
0088     #ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
0089 
0090     // Serialization support
0091 
0092     template< class Archive >
0093     void serialize(Archive & ar, const unsigned int v)
0094     {
0095         boost::core::split_member(ar, *this, v);
0096     }
0097 
0098     friend class ::boost::serialization::access;
0099 
0100     template< class Archive >
0101     void save(Archive & ar, const unsigned int) const
0102     {
0103         ar << ::boost::serialization::make_nvp("mi_iterator",this->base());
0104     }
0105 
0106     template< class Archive >
0107     void load(Archive & ar, const unsigned int)
0108     {
0109         CoreIterator iter;
0110         ar >> ::boost::serialization::make_nvp("mi_iterator",iter);
0111         this->base_reference() = iter;
0112     }
0113 
0114     #endif // BOOST_BIMAP_DISABLE_SERIALIZATION
0115 };
0116 
0117 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0118 
0119 template< class CoreIterator > struct const_set_view_iterator;
0120 
0121 template< class CoreIterator >
0122 struct const_set_view_iterator_base
0123 {
0124     typedef iterator_adaptor
0125     <
0126         const_set_view_iterator< CoreIterator >,
0127         CoreIterator,
0128         const BOOST_DEDUCED_TYPENAME CoreIterator::value_type::above_view
0129 
0130     > type;
0131 };
0132 
0133 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0134 
0135 
0136 /** \brief Const Set View Iterator adaptor from multi index to bimap.
0137 
0138 See also set_view_iterator.
0139                                                                       **/
0140 
0141 template< class CoreIterator >
0142 struct const_set_view_iterator : public const_set_view_iterator_base<CoreIterator>::type
0143 {
0144     typedef BOOST_DEDUCED_TYPENAME const_set_view_iterator_base<CoreIterator>::type base_;
0145 
0146     public:
0147 
0148     const_set_view_iterator() {}
0149 
0150     const_set_view_iterator(CoreIterator const& iter)
0151       : base_(iter) {}
0152 
0153     const_set_view_iterator(const_set_view_iterator const & iter)
0154       : base_(iter.base()) {}
0155 
0156     const_set_view_iterator(set_view_iterator<CoreIterator> i)
0157       : base_(i.base()) {}
0158 
0159     BOOST_DEDUCED_TYPENAME base_::reference dereference() const
0160     {
0161         return this->base()->get_view();
0162     }
0163 
0164     private:
0165 
0166     friend class boost::iterators::iterator_core_access;
0167 
0168     #ifndef BOOST_BIMAP_DISABLE_SERIALIZATION
0169 
0170     // Serialization support
0171 
0172     template< class Archive >
0173     void serialize(Archive & ar, const unsigned int v)
0174     {
0175         boost::core::split_member(ar, *this, v);
0176     }
0177 
0178     friend class ::boost::serialization::access;
0179 
0180     template< class Archive >
0181     void save(Archive & ar, const unsigned int) const
0182     {
0183         ar << ::boost::serialization::make_nvp("mi_iterator",this->base());
0184     }
0185 
0186     template< class Archive >
0187     void load(Archive & ar, const unsigned int)
0188     {
0189         CoreIterator iter;
0190         ar >> ::boost::serialization::make_nvp("mi_iterator",iter);
0191         this->base_reference() = iter;
0192     }
0193 
0194     #endif // BOOST_BIMAP_DISABLE_SERIALIZATION
0195 };
0196 
0197 
0198 } // namespace detail
0199 } // namespace bimaps
0200 } // namespace boost
0201 
0202 #endif // BOOST_BIMAP_DETAIL_MAP_VIEW_ITERATOR_HPP
0203 
0204