Blender
V5.0
source
blender
blenlib
BLI_random_access_iterator_mixin.hh
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2024 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9
#pragma once
10
11
#include <iterator>
12
13
namespace
blender::iterator
{
14
27
template
<
typename
Derived>
class
RandomAccessIteratorMixin
{
28
public
:
29
using
iterator_category
= std::random_access_iterator_tag;
30
using
difference_type
= std::ptrdiff_t;
31
32
constexpr
friend
Derived &
operator++
(Derived &a)
33
{
34
++a.iter_prop_mutable();
35
return
a;
36
}
37
38
constexpr
friend
Derived
operator++
(Derived &a,
int
)
39
{
40
Derived
copy
= a;
41
++a;
42
return
copy
;
43
}
44
45
constexpr
friend
Derived &
operator--
(Derived &a)
46
{
47
--a.iter_prop_mutable();
48
return
a;
49
}
50
51
constexpr
friend
Derived
operator--
(Derived &a,
int
)
52
{
53
Derived
copy
= a;
54
--a;
55
return
copy
;
56
}
57
58
constexpr
friend
Derived &
operator+=
(Derived &a,
const
std::ptrdiff_t n)
59
{
60
a.iter_prop_mutable() += n;
61
return
a;
62
}
63
64
constexpr
friend
Derived &
operator-=
(Derived &a,
const
std::ptrdiff_t n)
65
{
66
a.iter_prop_mutable() -= n;
67
return
a;
68
}
69
70
constexpr
friend
Derived
operator+
(
const
Derived &a,
const
std::ptrdiff_t n)
71
{
72
Derived
copy
= a;
73
copy
.iter_prop_mutable() += n;
74
return
copy
;
75
}
76
77
constexpr
friend
Derived
operator-
(
const
Derived &a,
const
std::ptrdiff_t n)
78
{
79
Derived
copy
= a;
80
copy
.iter_prop_mutable() -= n;
81
return
copy
;
82
}
83
84
constexpr
friend
auto
operator-
(
const
Derived &a,
const
Derived &
b
)
85
{
86
return
a.iter_prop() -
b
.iter_prop();
87
}
88
89
constexpr
friend
bool
operator!=
(
const
Derived &a,
const
Derived &
b
)
90
{
91
return
a.iter_prop() !=
b
.iter_prop();
92
}
93
94
constexpr
friend
bool
operator==
(
const
Derived &a,
const
Derived &
b
)
95
{
96
return
a.iter_prop() ==
b
.iter_prop();
97
}
98
99
constexpr
friend
bool
operator<
(
const
Derived &a,
const
Derived &
b
)
100
{
101
return
a.iter_prop() <
b
.iter_prop();
102
}
103
104
constexpr
friend
bool
operator>
(
const
Derived &a,
const
Derived &
b
)
105
{
106
return
a.iter_prop() >
b
.iter_prop();
107
}
108
109
constexpr
friend
bool
operator<=
(
const
Derived &a,
const
Derived &
b
)
110
{
111
return
a.iter_prop() <=
b
.iter_prop();
112
}
113
114
constexpr
friend
bool
operator>=
(
const
Derived &a,
const
Derived &
b
)
115
{
116
return
a.iter_prop() >=
b
.iter_prop();
117
}
118
119
constexpr
decltype
(
auto
)
operator
[](
const
std::ptrdiff_t
i
)
120
{
121
return
*(*
static_cast<
Derived *
>
(
this
) +
i
);
122
}
123
124
constexpr
decltype
(
auto
)
operator
[](
const
std::ptrdiff_t
i
)
const
125
{
126
return
*(*
static_cast<
const
Derived *
>
(
this
) +
i
);
127
}
128
129
auto
&
iter_prop_mutable
()
130
{
131
const
auto
&const_iter_prop =
static_cast<
const
Derived *
>
(
this
)->iter_prop();
132
return
const_cast<
std::remove_const_t<std::remove_reference_t<decltype(const_iter_prop)
>
> &>(
133
const_iter_prop);
134
}
135
};
136
137
}
// namespace blender::iterator
blender::iterator::RandomAccessIteratorMixin
Definition
BLI_random_access_iterator_mixin.hh:27
blender::iterator::RandomAccessIteratorMixin::operator-
constexpr friend Derived operator-(const Derived &a, const std::ptrdiff_t n)
Definition
BLI_random_access_iterator_mixin.hh:77
blender::iterator::RandomAccessIteratorMixin::iter_prop_mutable
auto & iter_prop_mutable()
Definition
BLI_random_access_iterator_mixin.hh:129
blender::iterator::RandomAccessIteratorMixin::operator++
constexpr friend Derived operator++(Derived &a, int)
Definition
BLI_random_access_iterator_mixin.hh:38
blender::iterator::RandomAccessIteratorMixin::difference_type
std::ptrdiff_t difference_type
Definition
BLI_random_access_iterator_mixin.hh:30
blender::iterator::RandomAccessIteratorMixin::operator+
constexpr friend Derived operator+(const Derived &a, const std::ptrdiff_t n)
Definition
BLI_random_access_iterator_mixin.hh:70
blender::iterator::RandomAccessIteratorMixin::operator--
constexpr friend Derived operator--(Derived &a, int)
Definition
BLI_random_access_iterator_mixin.hh:51
blender::iterator::RandomAccessIteratorMixin::operator--
constexpr friend Derived & operator--(Derived &a)
Definition
BLI_random_access_iterator_mixin.hh:45
blender::iterator::RandomAccessIteratorMixin::operator-
constexpr friend auto operator-(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:84
blender::iterator::RandomAccessIteratorMixin::iterator_category
std::random_access_iterator_tag iterator_category
Definition
BLI_random_access_iterator_mixin.hh:29
blender::iterator::RandomAccessIteratorMixin::operator-=
constexpr friend Derived & operator-=(Derived &a, const std::ptrdiff_t n)
Definition
BLI_random_access_iterator_mixin.hh:64
blender::iterator::RandomAccessIteratorMixin::operator>
constexpr friend bool operator>(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:104
blender::iterator::RandomAccessIteratorMixin::operator<
constexpr friend bool operator<(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:99
blender::iterator::RandomAccessIteratorMixin::operator<=
constexpr friend bool operator<=(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:109
blender::iterator::RandomAccessIteratorMixin::operator++
constexpr friend Derived & operator++(Derived &a)
Definition
BLI_random_access_iterator_mixin.hh:32
blender::iterator::RandomAccessIteratorMixin::operator==
constexpr friend bool operator==(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:94
blender::iterator::RandomAccessIteratorMixin::operator!=
constexpr friend bool operator!=(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:89
blender::iterator::RandomAccessIteratorMixin::operator+=
constexpr friend Derived & operator+=(Derived &a, const std::ptrdiff_t n)
Definition
BLI_random_access_iterator_mixin.hh:58
blender::iterator::RandomAccessIteratorMixin::operator>=
constexpr friend bool operator>=(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:114
b
b
Definition
compositor_morphological_distance_infos.hh:24
blender::iterator
Definition
BLI_random_access_iterator_mixin.hh:13
copy
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
Definition
node_texture_output.cc:130
i
i
Definition
text_draw.cc:230
Generated on
for Blender by
doxygen
1.16.1