Blender
V4.3
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
5
#pragma once
6
7
#include <iterator>
8
9
namespace
blender::iterator
{
10
23
template
<
typename
Derived>
class
RandomAccessIteratorMixin
{
24
public
:
25
using
iterator_category
= std::random_access_iterator_tag;
26
using
difference_type
= std::ptrdiff_t;
27
28
constexpr
friend
Derived &
operator++
(Derived &a)
29
{
30
++a.iter_prop_mutable();
31
return
a;
32
}
33
34
constexpr
friend
Derived
operator++
(Derived &a,
int
)
35
{
36
Derived
copy
= a;
37
++a;
38
return
copy
;
39
}
40
41
constexpr
friend
Derived &
operator--
(Derived &a)
42
{
43
--a.iter_prop_mutable();
44
return
a;
45
}
46
47
constexpr
friend
Derived
operator--
(Derived &a,
int
)
48
{
49
Derived
copy
= a;
50
--a;
51
return
copy
;
52
}
53
54
constexpr
friend
Derived &
operator+=
(Derived &a,
const
std::ptrdiff_t n)
55
{
56
a.iter_prop_mutable() += n;
57
return
a;
58
}
59
60
constexpr
friend
Derived &
operator-=
(Derived &a,
const
std::ptrdiff_t n)
61
{
62
a.iter_prop_mutable() -= n;
63
return
a;
64
}
65
66
constexpr
friend
Derived
operator+
(
const
Derived &a,
const
std::ptrdiff_t n)
67
{
68
Derived
copy
= a;
69
copy
.iter_prop_mutable() += n;
70
return
copy
;
71
}
72
73
constexpr
friend
Derived
operator-
(
const
Derived &a,
const
std::ptrdiff_t n)
74
{
75
Derived
copy
= a;
76
copy
.iter_prop_mutable() -= n;
77
return
copy
;
78
}
79
80
constexpr
friend
auto
operator-
(
const
Derived &a,
const
Derived &
b
)
81
{
82
return
a.iter_prop() -
b
.iter_prop();
83
}
84
85
constexpr
friend
bool
operator!=
(
const
Derived &a,
const
Derived &
b
)
86
{
87
return
a.iter_prop() !=
b
.iter_prop();
88
}
89
90
constexpr
friend
bool
operator==
(
const
Derived &a,
const
Derived &
b
)
91
{
92
return
a.iter_prop() ==
b
.iter_prop();
93
}
94
95
constexpr
friend
bool
operator<
(
const
Derived &a,
const
Derived &
b
)
96
{
97
return
a.iter_prop() <
b
.iter_prop();
98
}
99
100
constexpr
friend
bool
operator>
(
const
Derived &a,
const
Derived &
b
)
101
{
102
return
a.iter_prop() >
b
.iter_prop();
103
}
104
105
constexpr
friend
bool
operator<=
(
const
Derived &a,
const
Derived &
b
)
106
{
107
return
a.iter_prop() <=
b
.iter_prop();
108
}
109
110
constexpr
friend
bool
operator>=
(
const
Derived &a,
const
Derived &
b
)
111
{
112
return
a.iter_prop() >=
b
.iter_prop();
113
}
114
115
constexpr
decltype
(
auto
)
operator
[](
const
std::ptrdiff_t i)
116
{
117
return
*(*
static_cast<
Derived *
>
(
this
) + i);
118
}
119
120
constexpr
decltype
(
auto
)
operator
[](
const
std::ptrdiff_t i)
const
121
{
122
return
*(*
static_cast<
const
Derived *
>
(
this
) + i);
123
}
124
125
auto
&
iter_prop_mutable
()
126
{
127
const
auto
&const_iter_prop =
static_cast<
const
Derived *
>
(
this
)->iter_prop();
128
return
const_cast<
std::remove_const_t<std::remove_reference_t<decltype(const_iter_prop)
>
> &>(
129
const_iter_prop);
130
}
131
};
132
133
}
// namespace blender::iterator
blender::iterator::RandomAccessIteratorMixin
Definition
BLI_random_access_iterator_mixin.hh:23
blender::iterator::RandomAccessIteratorMixin::operator-
constexpr friend Derived operator-(const Derived &a, const std::ptrdiff_t n)
Definition
BLI_random_access_iterator_mixin.hh:73
blender::iterator::RandomAccessIteratorMixin::iter_prop_mutable
auto & iter_prop_mutable()
Definition
BLI_random_access_iterator_mixin.hh:125
blender::iterator::RandomAccessIteratorMixin::operator++
constexpr friend Derived operator++(Derived &a, int)
Definition
BLI_random_access_iterator_mixin.hh:34
blender::iterator::RandomAccessIteratorMixin::difference_type
std::ptrdiff_t difference_type
Definition
BLI_random_access_iterator_mixin.hh:26
blender::iterator::RandomAccessIteratorMixin::operator+
constexpr friend Derived operator+(const Derived &a, const std::ptrdiff_t n)
Definition
BLI_random_access_iterator_mixin.hh:66
blender::iterator::RandomAccessIteratorMixin::operator--
constexpr friend Derived operator--(Derived &a, int)
Definition
BLI_random_access_iterator_mixin.hh:47
blender::iterator::RandomAccessIteratorMixin::operator--
constexpr friend Derived & operator--(Derived &a)
Definition
BLI_random_access_iterator_mixin.hh:41
blender::iterator::RandomAccessIteratorMixin::operator-
constexpr friend auto operator-(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:80
blender::iterator::RandomAccessIteratorMixin::iterator_category
std::random_access_iterator_tag iterator_category
Definition
BLI_random_access_iterator_mixin.hh:25
blender::iterator::RandomAccessIteratorMixin::operator-=
constexpr friend Derived & operator-=(Derived &a, const std::ptrdiff_t n)
Definition
BLI_random_access_iterator_mixin.hh:60
blender::iterator::RandomAccessIteratorMixin::operator>
constexpr friend bool operator>(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:100
blender::iterator::RandomAccessIteratorMixin::operator<
constexpr friend bool operator<(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:95
blender::iterator::RandomAccessIteratorMixin::operator<=
constexpr friend bool operator<=(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:105
blender::iterator::RandomAccessIteratorMixin::operator++
constexpr friend Derived & operator++(Derived &a)
Definition
BLI_random_access_iterator_mixin.hh:28
blender::iterator::RandomAccessIteratorMixin::operator==
constexpr friend bool operator==(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:90
blender::iterator::RandomAccessIteratorMixin::operator!=
constexpr friend bool operator!=(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:85
blender::iterator::RandomAccessIteratorMixin::operator+=
constexpr friend Derived & operator+=(Derived &a, const std::ptrdiff_t n)
Definition
BLI_random_access_iterator_mixin.hh:54
blender::iterator::RandomAccessIteratorMixin::operator>=
constexpr friend bool operator>=(const Derived &a, const Derived &b)
Definition
BLI_random_access_iterator_mixin.hh:110
b
local_group_size(16, 16) .push_constant(Type b
Definition
compositor_morphological_distance_info.hh:16
blender::iterator
Definition
BLI_random_access_iterator_mixin.hh:9
copy
static void copy(bNodeTree *dest_ntree, bNode *dest_node, const bNode *src_node)
Definition
node_texture_output.cc:130
Generated on Thu Feb 6 2025 07:36:39 for Blender by
doxygen
1.11.0