Back to home page

EIC code displayed by LXR

 
 

    


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

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