annotate DEPENDENCIES/generic/include/boost/archive/iterators/head_iterator.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 #ifndef BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP
Chris@16 2 #define BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP
Chris@16 3
Chris@16 4 // MS compatible compilers support #pragma once
Chris@101 5 #if defined(_MSC_VER)
Chris@16 6 # pragma once
Chris@16 7 #endif
Chris@16 8
Chris@16 9 /////////1/////////2/////////3/////////4/////////5/////////6/////////7/////////8
Chris@16 10 // head_iterator.hpp
Chris@16 11
Chris@16 12 // (C) Copyright 2002 Robert Ramey - http://www.rrsd.com .
Chris@16 13 // Use, modification and distribution is subject to the Boost Software
Chris@16 14 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 15 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 16
Chris@16 17 // See http://www.boost.org for updates, documentation, and revision history.
Chris@16 18
Chris@16 19 #include <boost/iterator/iterator_adaptor.hpp>
Chris@16 20 #include <boost/iterator/iterator_traits.hpp>
Chris@16 21
Chris@16 22 namespace boost {
Chris@16 23 namespace archive {
Chris@16 24 namespace iterators {
Chris@16 25
Chris@16 26 template<class Predicate, class Base>
Chris@16 27 class head_iterator
Chris@16 28 : public boost::iterator_adaptor<
Chris@16 29 head_iterator<Predicate, Base>,
Chris@16 30 Base,
Chris@16 31 use_default,
Chris@16 32 single_pass_traversal_tag
Chris@16 33 >
Chris@16 34 {
Chris@16 35 private:
Chris@16 36 friend class iterator_core_access;
Chris@16 37 typedef boost::iterator_adaptor<
Chris@16 38 head_iterator<Predicate, Base>,
Chris@16 39 Base,
Chris@16 40 use_default,
Chris@16 41 single_pass_traversal_tag
Chris@16 42 > super_t;
Chris@16 43
Chris@16 44 typedef head_iterator<Predicate, Base> this_t;
Chris@16 45 typedef super_t::value_type value_type;
Chris@16 46 typedef super_t::reference reference_type;
Chris@16 47
Chris@16 48 reference_type dereference_impl(){
Chris@16 49 if(! m_end){
Chris@16 50 while(! m_predicate(* this->base_reference()))
Chris@16 51 ++ this->base_reference();
Chris@16 52 m_end = true;
Chris@16 53 }
Chris@16 54 return * this->base_reference();
Chris@16 55 }
Chris@16 56
Chris@16 57 reference_type dereference() const {
Chris@16 58 return const_cast<this_t *>(this)->dereference_impl();
Chris@16 59 }
Chris@16 60
Chris@16 61 void increment(){
Chris@16 62 ++base_reference();
Chris@16 63 }
Chris@16 64 Predicate m_predicate;
Chris@16 65 bool m_end;
Chris@16 66 public:
Chris@16 67 template<class T>
Chris@16 68 head_iterator(Predicate f, T start) :
Chris@16 69 super_t(Base(start)),
Chris@16 70 m_predicate(f),
Chris@16 71 m_end(false)
Chris@16 72 {}
Chris@16 73
Chris@16 74 };
Chris@16 75
Chris@16 76 } // namespace iterators
Chris@16 77 } // namespace archive
Chris@16 78 } // namespace boost
Chris@16 79
Chris@16 80 #endif // BOOST_ARCHIVE_ITERATORS_HEAD_ITERATOR_HPP