Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/ps/tests/test_Future.h
Show First 20 Lines • Show All 118 Lines • ▼ Show 20 Lines | void test_future_moving() | ||||
memset(&futureStorage, 0xFF, sizeof(decltype(futureStorage))); | memset(&futureStorage, 0xFF, sizeof(decltype(futureStorage))); | ||||
memset(&functionStorage, 0xFF, sizeof(decltype(functionStorage))); | memset(&functionStorage, 0xFF, sizeof(decltype(functionStorage))); | ||||
// Let's move the packaged task while at it. | // Let's move the packaged task while at it. | ||||
std::function<void()> task2 = std::move(task); | std::function<void()> task2 = std::move(task); | ||||
task2(); | task2(); | ||||
TS_ASSERT_EQUALS(future.Get(), 7); | TS_ASSERT_EQUALS(future.Get(), 7); | ||||
} | } | ||||
void test_move_only_function() | |||||
{ | |||||
Future<void> future; | |||||
class MoveOnlyType | |||||
{ | |||||
public: | |||||
MoveOnlyType() = default; | |||||
MoveOnlyType(MoveOnlyType&) = delete; | |||||
MoveOnlyType& operator=(MoveOnlyType&) = delete; | |||||
MoveOnlyType(MoveOnlyType&&) = default; | |||||
MoveOnlyType& operator=(MoveOnlyType&&) = default; | |||||
}; | |||||
future.Wrap([t = MoveOnlyType{}]{}); | |||||
} | |||||
}; | }; |
Wildfire Games · Phabricator