Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:47:48

0001 /* Copyright 2016 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See http://www.boost.org/libs/poly_collection for library home page.
0007  */
0008 
0009 #ifndef BOOST_POLY_COLLECTION_DETAIL_AUTO_ITERATOR_HPP
0010 #define BOOST_POLY_COLLECTION_DETAIL_AUTO_ITERATOR_HPP
0011 
0012 #if defined(_MSC_VER)
0013 #pragma once
0014 #endif
0015 
0016 #include <boost/iterator/iterator_adaptor.hpp>
0017 
0018 namespace boost{
0019 
0020 namespace poly_collection{
0021 
0022 namespace detail{
0023 
0024 /* auto_iterator<Iterator> (for want of a better name) behaves like Iterator
0025  * save for the fact that it derefs to Iterator& rather than
0026  * Iterator::reference. This is useful to "lift" std algorithms so that
0027  * user-defined predicates are passed iterators that can then be dereferenced
0028  * internally.
0029  */
0030 
0031 template<typename Iterator>
0032 class auto_iterator:
0033   public boost::iterator_adaptor<auto_iterator<Iterator>,Iterator,Iterator>
0034 {
0035 public:
0036   auto_iterator()=default;
0037   auto_iterator(const Iterator& it):auto_iterator::iterator_adaptor_{it}{}
0038   auto_iterator(const auto_iterator&)=default;
0039   auto_iterator& operator=(const auto_iterator&)=default;
0040 
0041 private:
0042   friend class boost::iterator_core_access;
0043 
0044   Iterator& dereference()const noexcept
0045   {
0046     return const_cast<auto_iterator*>(this)->base_reference();
0047   }
0048 };
0049 
0050 } /* namespace poly_collection::detail */
0051 
0052 } /* namespace poly_collection */
0053 
0054 } /* namespace boost */
0055 
0056 #endif