Created
February 28, 2024 17:36
-
-
Save sthalik/e46eeefa503c850e9f50fd1b35b53812 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git src/Corrade/Utility/Move.h src/Corrade/Utility/Move.h | |
index e0713b74..edfa9432 100644 | |
--- src/Corrade/Utility/Move.h | |
+++ src/Corrade/Utility/Move.h | |
@@ -53,7 +53,11 @@ is used to implement perfect forwarding, but without the | |
even in C++11. | |
@see @ref move(), @ref swap() | |
*/ | |
-template<class T> constexpr T&& forward(typename std::remove_reference<T>::type& t) noexcept { | |
+template<class T> | |
+#ifdef CORRADE_TARGET_CXX20 | |
+requires true | |
+#endif | |
+constexpr T&& forward(typename std::remove_reference<T>::type& t) noexcept { | |
return static_cast<T&&>(t); | |
} | |
@@ -67,7 +71,11 @@ is used to implement perfect forwarding, but without the | |
even in C++11. | |
@see @ref move(), @ref swap() | |
*/ | |
-template<class T> constexpr T&& forward(typename std::remove_reference<T>::type&& t) noexcept { | |
+template<class T> | |
+#ifdef CORRADE_TARGET_CXX20 | |
+requires true | |
+#endif | |
+constexpr T&& forward(typename std::remove_reference<T>::type&& t) noexcept { | |
/* bits/move.h in libstdc++ has this and it makes sense to have it here | |
also, although I can't really explain what accidents it prevents */ | |
static_assert(!std::is_lvalue_reference<T>::value, "T can't be a lvalue reference"); | |
@@ -84,7 +92,11 @@ but without the @cpp #include <utility> @ce dependency and guaranteed to be | |
@cpp constexpr @ce even in C++11. | |
@see @ref forward(), @ref swap() | |
*/ | |
-template<class T> constexpr typename std::remove_reference<T>::type&& move(T&& t) noexcept { | |
+template<class T> | |
+#ifdef CORRADE_TARGET_CXX20 | |
+requires true | |
+#endif | |
+constexpr typename std::remove_reference<T>::type&& move(T&& t) noexcept { | |
return static_cast<typename std::remove_reference<T>::type&&>(t); | |
} | |
diff --git src/Corrade/Utility/Test/MoveTest.cpp src/Corrade/Utility/Test/MoveTest.cpp | |
index 5efbe1d3..e0627b92 100644 | |
--- src/Corrade/Utility/Test/MoveTest.cpp | |
+++ src/Corrade/Utility/Test/MoveTest.cpp | |
@@ -34,11 +34,13 @@ | |
namespace Corrade { namespace Utility { namespace Test { namespace { | |
+using Utility::move; | |
+ | |
struct MoveTest: TestSuite::Tester { | |
explicit MoveTest(); | |
void forward(); | |
- void move(); | |
+ void move_(); | |
void swap(); | |
void swapArray(); | |
@@ -52,7 +54,7 @@ struct MoveTest: TestSuite::Tester { | |
MoveTest::MoveTest() { | |
addTests({&MoveTest::forward, | |
- &MoveTest::move, | |
+ &MoveTest::move_, | |
&MoveTest::swap, | |
&MoveTest::swapArray, | |
@@ -104,15 +106,15 @@ void MoveTest::forward() { | |
CORRADE_COMPARE(cc.a, 7); | |
} | |
-void MoveTest::move() { | |
+void MoveTest::move_() { | |
Foo a; | |
/* It makes sense to take std::move() as a ground truth */ | |
CORRADE_VERIFY(std::is_same<decltype(std::move(a)), Foo&&>::value); | |
- CORRADE_VERIFY(std::is_same<decltype(Utility::move(a)), Foo&&>::value); | |
+ CORRADE_VERIFY(std::is_same<decltype(move(a)), Foo&&>::value); | |
CORRADE_VERIFY(std::is_same<decltype(std::move(ca)), const Foo&&>::value); | |
- CORRADE_VERIFY(std::is_same<decltype(Utility::move(ca)), const Foo&&>::value); | |
+ CORRADE_VERIFY(std::is_same<decltype(move(ca)), const Foo&&>::value); | |
constexpr Foo cb = Utility::move(ca); | |
CORRADE_COMPARE(cb.a, 5); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment