Adobe Source Libraries 1.49.0
A collection of C++ libraries.
Loading...
Searching...
No Matches
value_iterator.hpp
Go to the documentation of this file.
1/*
2 Copyright 2013 Adobe
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5*/
6/**************************************************************************************************/
7
8#ifndef ADOBE_ITERATOR_VALUE_ITERATOR_HPP
9#define ADOBE_ITERATOR_VALUE_ITERATOR_HPP
10
11#include <adobe/config.hpp>
12
13#include <cassert>
14#include <functional>
15#include <iterator>
16
17#include <adobe/functional.hpp>
18#include <adobe/type_traits.hpp>
19
20/**************************************************************************************************/
21
22namespace adobe {
23
24/**************************************************************************************************/
25
28
29
30template <typename I, // I models Incrementable
31 typename F = identity<I>> // F models UnaryFunction
33public:
37 typedef ptrdiff_t difference_type;
38 typedef std::forward_iterator_tag iterator_category;
39
40private:
41 I i;
42 F f;
43
44public:
46
47 value_iterator(const I& x, const F& y) : i(x), f(y) {}
48
50 ++i;
51 return *this;
52 }
53
55 value_iterator tmp = *this;
56
57 ++*this;
58
59 return tmp;
60 }
61
62 const value_type& operator*() const { return f(i); }
63
64 value_type operator*() { return f(i); }
65
66 friend bool operator==(const value_iterator& a, const value_iterator& b) {
67 // assert(a.f == b.f);
68
69 return a.i == b.i;
70 }
71
72 friend bool operator!=(const value_iterator& a, const value_iterator& b) { return !(a == b); }
73};
74
76
77/**************************************************************************************************/
78
79} // namespace adobe
80
81/**************************************************************************************************/
82
83#endif
84// ADOBE_ITERATOR_DISTANCE_HPP
std::forward_iterator_tag iterator_category
value_iterator(const I &x, const F &y)
value_iterator operator++(int)
const value_type & operator*() const
value_iterator & operator++()
friend bool operator==(const value_iterator &a, const value_iterator &b)
adobe::invoke_result_t< F, I > value_type
friend bool operator!=(const value_iterator &a, const value_iterator &b)
std::result_of_t< F(Args...)> invoke_result_t