20
Memory management library
[mem]
20.3
Smart pointers
[smartptr]
20.3.2
Shared-ownership pointers
[util.sharedptr]
20.3.2.4
Class template
owner_
less
[util.smartptr.ownerless]
1
#
The class template
owner_
less
allows ownership-based mixed comparisons of shared and weak pointers
.
🔗
namespace
std
{
template
<
class
T
=
void
>
struct
owner_less;
template
<
class
T
>
struct
owner_less
<
shared_ptr
<
T
>
>
{
bool
operator
(
)
(
const
shared_ptr
<
T
>
&
,
const
shared_ptr
<
T
>
&
)
const
noexcept
;
bool
operator
(
)
(
const
shared_ptr
<
T
>
&
,
const
weak_ptr
<
T
>
&
)
const
noexcept
;
bool
operator
(
)
(
const
weak_ptr
<
T
>
&
,
const
shared_ptr
<
T
>
&
)
const
noexcept
;
}
;
template
<
class
T
>
struct
owner_less
<
weak_ptr
<
T
>
>
{
bool
operator
(
)
(
const
weak_ptr
<
T
>
&
,
const
weak_ptr
<
T
>
&
)
const
noexcept
;
bool
operator
(
)
(
const
shared_ptr
<
T
>
&
,
const
weak_ptr
<
T
>
&
)
const
noexcept
;
bool
operator
(
)
(
const
weak_ptr
<
T
>
&
,
const
shared_ptr
<
T
>
&
)
const
noexcept
;
}
;
template
<
>
struct
owner_less
<
void
>
{
template
<
class
T,
class
U
>
bool
operator
(
)
(
const
shared_ptr
<
T
>
&
,
const
shared_ptr
<
U
>
&
)
const
noexcept
;
template
<
class
T,
class
U
>
bool
operator
(
)
(
const
shared_ptr
<
T
>
&
,
const
weak_ptr
<
U
>
&
)
const
noexcept
;
template
<
class
T,
class
U
>
bool
operator
(
)
(
const
weak_ptr
<
T
>
&
,
const
shared_ptr
<
U
>
&
)
const
noexcept
;
template
<
class
T,
class
U
>
bool
operator
(
)
(
const
weak_ptr
<
T
>
&
,
const
weak_ptr
<
U
>
&
)
const
noexcept
;
using
is_transparent
=
unspecified
;
}
;
}
2
#
operator
(
)
(
x, y
)
returns
x
.
owner_
before
(
y
)
.
[
Note
1
:
Note that
(2.1)
operator
(
)
defines a strict weak ordering as defined in
[alg.
sorting]
;
(2.2)
two
shared_
ptr
or
weak_
ptr
instances are equivalent under the equivalence relation defined by
operator
(
)
,
!
operator
(
)
(
a, b
)
&
&
!
operator
(
)
(
b, a
)
, if and only if they share ownership or are both empty
.
—
end note
]