17
Language support library
[support]
17.11
Comparisons
[cmp]
17.11.4
Concept
three_way_comparable
[cmp.concept]
template
<
class
T,
class
Cat
>
concept
compares-as
=
//
exposition only
same_as
<
common_comparison_category_t
<
T, Cat
>
, Cat
>
;
template
<
class
T,
class
U
>
concept
partially-ordered-with
=
//
exposition only
requires
(
const
remove_reference_t
<
T
>
&
t,
const
remove_reference_t
<
U
>
&
u
)
{
{
t
<
u
}
-
>
boolean-testable
;
{
t
>
u
}
-
>
boolean-testable
;
{
t
<
=
u
}
-
>
boolean-testable
;
{
t
>
=
u
}
-
>
boolean-testable
;
{
u
<
t
}
-
>
boolean-testable
;
{
u
>
t
}
-
>
boolean-testable
;
{
u
<
=
t
}
-
>
boolean-testable
;
{
u
>
=
t
}
-
>
boolean-testable
;
}
;
1
#
Let
t
and
u
be lvalues of types
const
remove_reference_t
<
T
>
and
const
remove_reference_t
<
U
>
, respectively
.
T
and
U
model
partially-ordered-with
<
T, U
>
only if:
(1.1)
t
<
u
,
t
<
=
u
,
t
>
u
,
t
>
=
u
,
u
<
t
,
u
<
=
t
,
u
>
t
, and
u
>
=
t
have the same domain
.
(1.2)
bool
(
t
<
u
)
=
=
bool
(
u
>
t
)
is
true
,
(1.3)
bool
(
u
<
t
)
=
=
bool
(
t
>
u
)
is
true
,
(1.4)
bool
(
t
<
=
u
)
=
=
bool
(
u
>
=
t
)
is
true
, and
(1.5)
bool
(
u
<
=
t
)
=
=
bool
(
t
>
=
u
)
is
true
.
template
<
class
T,
class
Cat
=
partial_ordering
>
concept
three_way_comparable
=
weakly-equality-comparable-with
<
T, T
>
&
&
partially-ordered-with
<
T, T
>
&
&
requires
(
const
remove_reference_t
<
T
>
&
a,
const
remove_reference_t
<
T
>
&
b
)
{
{
a
<
=
>
b
}
-
>
compares-as
<
Cat
>
;
}
;
2
#
Let
a
and
b
be lvalues of type
const
remove_reference_t
<
T
>
.
T
and
Cat
model
three_way_comparable
<
T, Cat
>
only if:
(2.1)
(
a
<
=
>
b
=
=
0
)
=
=
bool
(
a
=
=
b
)
is
true
,
(2.2)
(
a
<
=
>
b
!
=
0
)
=
=
bool
(
a
!
=
b
)
is
true
,
(2.3)
(
(
a
<
=
>
b
)
<
=
>
0
)
and
(
0
<
=
>
(
b
<
=
>
a
)
)
are equal,
(2.4)
(
a
<
=
>
b
<
0
)
=
=
bool
(
a
<
b
)
is
true
,
(2.5)
(
a
<
=
>
b
>
0
)
=
=
bool
(
a
>
b
)
is
true
,
(2.6)
(
a
<
=
>
b
<
=
0
)
=
=
bool
(
a
<
=
b
)
is
true
,
(2.7)
(
a
<
=
>
b
>
=
0
)
=
=
bool
(
a
>
=
b
)
is
true
, and
(2.8)
if
Cat
is convertible to
strong_ordering
,
T
models
totally_ordered
(
[concept.
totallyordered]
)
.
template
<
class
T,
class
U,
class
Cat
=
partial_ordering
>
concept
three_way_comparable_with
=
three_way_comparable
<
T, Cat
>
&
&
three_way_comparable
<
U, Cat
>
&
&
common_reference_with
<
const
remove_reference_t
<
T
>
&
,
const
remove_reference_t
<
U
>
&
>
&
&
three_way_comparable
<
common_reference_t
<
const
remove_reference_t
<
T
>
&
,
const
remove_reference_t
<
U
>
&
>
, Cat
>
&
&
weakly-equality-comparable-with
<
T, U
>
&
&
partially-ordered-with
<
T, U
>
&
&
requires
(
const
remove_reference_t
<
T
>
&
t,
const
remove_reference_t
<
U
>
&
u
)
{
{
t
<
=
>
u
}
-
>
compares-as
<
Cat
>
;
{
u
<
=
>
t
}
-
>
compares-as
<
Cat
>
;
}
;
3
#
Let
t
and
u
be lvalues of types
const
remove_reference_t
<
T
>
and
const
remove_reference_t
<
U
>
, respectively
.
Let
C
be
common_reference_t
<
const
remove_reference_t
<
T
>
&
,
const
remove_reference_t
<
U
>
&
>
.
T
,
U
, and
Cat
model
three_way_comparable_with
<
T, U, Cat
>
only if:
(3.1)
t
<
=
>
u
and
u
<
=
>
t
have the same domain,
(3.2)
(
(
t
<
=
>
u
)
<
=
>
0
)
and
(
0
<
=
>
(
u
<
=
>
t
)
)
are equal,
(3.3)
(
t
<
=
>
u
=
=
0
)
=
=
bool
(
t
=
=
u
)
is
true
,
(3.4)
(
t
<
=
>
u
!
=
0
)
=
=
bool
(
t
!
=
u
)
is
true
,
(3.5)
Cat
(
t
<
=
>
u
)
=
=
Cat
(
C
(
t
)
<
=
>
C
(
u
)
)
is
true
,
(3.6)
(
t
<
=
>
u
<
0
)
=
=
bool
(
t
<
u
)
is
true
,
(3.7)
(
t
<
=
>
u
>
0
)
=
=
bool
(
t
>
u
)
is
true
,
(3.8)
(
t
<
=
>
u
<
=
0
)
=
=
bool
(
t
<
=
u
)
is
true
,
(3.9)
(
t
<
=
>
u
>
=
0
)
=
=
bool
(
t
>
=
u
)
is
true
, and
(3.10)
if
Cat
is convertible to
strong_ordering
,
T
and
U
model
totally_ordered_with
<
T, U
>
(
[concept.
totallyordered]
)
.