Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Jan Koniarik
emlabcpp
Commits
81ffb99f
Commit
81ffb99f
authored
Jun 02, 2021
by
Jan Koniarik
Browse files
moved iterators to operator<=> and operator==
parent
961e6c0e
Pipeline
#93968
passed with stage
in 39 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
include/emlabcpp/iterator.h
View file @
81ffb99f
...
...
@@ -82,10 +82,9 @@ class generic_iterator {
return
copy
;
}
constexpr
bool
operator
<
(
const
generic_iterator
<
Derived
>
&
other
)
const
{
return
impl
()
<
other
.
impl
();
constexpr
auto
operator
<
=>
(
const
generic_iterator
<
Derived
>
&
other
)
const
{
return
impl
()
<
=>
other
.
impl
();
}
constexpr
bool
operator
==
(
const
generic_iterator
<
Derived
>
&
other
)
const
{
return
impl
()
==
other
.
impl
();
}
...
...
@@ -103,31 +102,4 @@ class generic_iterator {
}
};
/// A > B iff B < A
template
<
typename
Derived
>
constexpr
bool
operator
>
(
const
generic_iterator
<
Derived
>
&
lh
,
const
generic_iterator
<
Derived
>
&
rh
)
{
return
rh
<
lh
;
}
/// A <= B iff !( B > A )
template
<
typename
Derived
>
constexpr
bool
operator
<=
(
const
generic_iterator
<
Derived
>
&
lh
,
const
generic_iterator
<
Derived
>
&
rh
)
{
return
!
(
lh
>
rh
);
}
/// A >= B iff !( B < A )
template
<
typename
Derived
>
constexpr
bool
operator
>=
(
const
generic_iterator
<
Derived
>
&
lh
,
const
generic_iterator
<
Derived
>
&
rh
)
{
return
!
(
lh
<
rh
);
}
/// A != B iff !( A == B)
template
<
typename
Derived
>
constexpr
bool
operator
!=
(
const
generic_iterator
<
Derived
>
&
lh
,
const
generic_iterator
<
Derived
>
&
rh
)
{
return
!
(
lh
==
rh
);
}
}
// namespace emlabcpp
include/emlabcpp/iterators/access.h
View file @
81ffb99f
...
...
@@ -49,8 +49,8 @@ class access_iterator : public generic_iterator<access_iterator<Iterator, Access
return
*
this
;
}
constexpr
bool
operator
<
(
const
access_iterator
&
other
)
const
{
return
current_
<
other
.
current_
;
constexpr
auto
operator
<
=>
(
const
access_iterator
&
other
)
const
{
return
current_
<
=>
other
.
current_
;
}
constexpr
bool
operator
==
(
const
access_iterator
&
other
)
const
{
return
current_
==
other
.
current_
;
...
...
include/emlabcpp/iterators/numeric.h
View file @
81ffb99f
...
...
@@ -45,8 +45,10 @@ class numeric_iterator : public generic_iterator<numeric_iterator<T>> {
return
*
this
;
}
constexpr
bool
operator
<
(
const
numeric_iterator
&
other
)
const
{
return
val_
<
other
.
val_
;
}
constexpr
bool
operator
==
(
const
numeric_iterator
&
other
)
const
{
constexpr
auto
operator
<=>
(
const
numeric_iterator
<
T
>
&
other
)
const
{
return
val_
<=>
other
.
val_
;
}
constexpr
auto
operator
==
(
const
numeric_iterator
<
T
>
&
other
)
const
{
return
val_
==
other
.
val_
;
}
...
...
include/emlabcpp/iterators/subscript.h
View file @
81ffb99f
...
...
@@ -51,7 +51,7 @@ class subscript_iterator : public generic_iterator<subscript_iterator<Container>
return
*
this
;
}
bool
operator
<
(
const
subscript_iterator
&
other
)
const
{
return
i_
<
other
.
i_
;
}
auto
operator
<
=>
(
const
subscript_iterator
&
other
)
const
{
return
i_
<
=>
other
.
i_
;
}
bool
operator
==
(
const
subscript_iterator
&
other
)
const
{
return
i_
==
other
.
i_
&&
&
cont_
==
&
other
.
cont_
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment