libbmb
Modern implementation of STL
Loading...
Searching...
No Matches
move.h
Go to the documentation of this file.
1
#pragma once
8
#include "
utils/type_traits.h
"
9
10
namespace
bmb
{
11
17
template
<
typename
T>
18
[[
nodiscard
(
"Move should be used to initialize other object"
)]]
19
constexpr
remove_ref_t<T>
&&
move
(
T
&& value)
noexcept
{
20
// Universal reference as a parameter allows to move already rvalue
21
// expressions. Therefore returning type should remove reference from the
22
// deduced type(see reference collapsing rules)
23
return
static_cast<
remove_ref_t<T>
&&
>
(value);
24
}
25
31
template
<
typename
T>
32
[[
nodiscard
(
"Forward should be used to initialize other object"
)]]
33
constexpr
T
&&
forward
(
remove_ref_t<T>
& value)
noexcept
{
34
return
static_cast<
T
&&
>
(value);
35
}
36
42
template
<
typename
T>
43
requires
(!
is_lvalue_ref_v<T>
)
44
[[
nodiscard
(
"Forward should be used to initialize other object"
)]]
45
constexpr
T
&&
forward
(
remove_ref_t<T>
&& value)
noexcept
{
46
return
static_cast<
T
&&
>
(value);
47
}
48
59
template
<
typename
T>
60
void
swap
(
T
&
x
,
T
&
y
) {
61
T
tmp
=
move
(
x
);
62
63
x
=
move
(
y
);
64
y
=
move
(
tmp
);
65
}
66
67
}
// namespace bmb
bmb
Definition
algo_base.h:14
bmb::move
constexpr remove_ref_t< T > && move(T &&value) noexcept
Convert a value to xvalue.
Definition
move.h:19
bmb::swap
void swap(LinkedList< T, TrackSize, TrackLast, Allocator > &a, LinkedList< T, TrackSize, TrackLast, Allocator > &b)
See LinkedList::swap
Definition
linked_list.h:1026
bmb::remove_ref_t
remove_ref< T >::type remove_ref_t
remove_ref_t
Definition
type_traits.h:182
bmb::forward
constexpr T && forward(remove_ref_t< T > &value) noexcept
Forward a lvalue.
Definition
move.h:33
type_traits.h
include
utils
move.h
Generated by
1.9.8