Skip to content

Commit 53697d4

Browse files
committed
Make take always move
Fixes #23
1 parent c3752db commit 53697d4

File tree

1 file changed

+2
-42
lines changed

1 file changed

+2
-42
lines changed

tl/optional.hpp

Lines changed: 2 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,32 +1032,12 @@ class optional : private detail::optional_move_assign_base<T>,
10321032
#endif
10331033

10341034
/// Takes the value out of the optional, leaving it empty
1035-
optional take() & {
1036-
optional ret = *this;
1037-
reset();
1038-
return ret;
1039-
}
1040-
1041-
optional take() const & {
1042-
optional ret = *this;
1043-
reset();
1044-
return ret;
1045-
}
1046-
1047-
optional take() && {
1035+
optional take() {
10481036
optional ret = std::move(*this);
10491037
reset();
10501038
return ret;
10511039
}
10521040

1053-
#ifndef TL_OPTIONAL_NO_CONSTRR
1054-
optional take() const && {
1055-
optional ret = std::move(*this);
1056-
reset();
1057-
return ret;
1058-
}
1059-
#endif
1060-
10611041
using value_type = T;
10621042

10631043
/// Constructs an optional that does not contain a value.
@@ -1926,32 +1906,12 @@ template <class T> class optional<T &> {
19261906
#endif
19271907

19281908
/// Takes the value out of the optional, leaving it empty
1929-
optional take() & {
1930-
optional ret = *this;
1931-
reset();
1932-
return ret;
1933-
}
1934-
1935-
optional take() const & {
1936-
optional ret = *this;
1937-
reset();
1938-
return ret;
1939-
}
1940-
1941-
optional take() && {
1909+
optional take() {
19421910
optional ret = std::move(*this);
19431911
reset();
19441912
return ret;
19451913
}
19461914

1947-
#ifndef TL_OPTIONAL_NO_CONSTRR
1948-
optional take() const && {
1949-
optional ret = std::move(*this);
1950-
reset();
1951-
return ret;
1952-
}
1953-
#endif
1954-
19551915
using value_type = T &;
19561916

19571917
/// Constructs an optional that does not contain a value.

0 commit comments

Comments
 (0)