MCPcopy Create free account
hub / github.com/catboost/catboost / TestApplyNoRvalueCopyImpl

Function TestApplyNoRvalueCopyImpl

library/cpp/threading/future/future_ut.cpp:591–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

589
590 template <typename T>
591 void TestApplyNoRvalueCopyImpl() {
592 size_t numCopies = 0;
593 TCopyCounter copyCounter(&numCopies);
594
595 auto promise = MakePromise<T>();
596
597 const auto future = promise.GetFuture().Apply(
598 [copyCounter = std::move(copyCounter)] (const auto&) {}
599 );
600
601 if constexpr (std::is_same_v<T, void>) {
602 promise.SetValue();
603 } else {
604 promise.SetValue(T());
605 }
606
607 future.GetValueSync();
608
609 UNIT_ASSERT_VALUES_EQUAL(numCopies, 0);
610 }
611
612 Y_UNIT_TEST(ApplyNoRvalueCopy) {
613 TestApplyNoRvalueCopyImpl<void>();

Callers

nothing calls this directly

Calls 6

GetValueSyncMethod · 0.80
moveFunction · 0.50
TClass · 0.50
ApplyMethod · 0.45
GetFutureMethod · 0.45
SetValueMethod · 0.45

Tested by

no test coverage detected