MCPcopy Create free account
hub / github.com/cameron314/readerwriterqueue / emplace

Method emplace

tests/unittests/unittests.cpp:648–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

646
647#if MOODYCAMEL_HAS_EMPLACE
648 bool emplace()
649 {
650 ReaderWriterQueue<UniquePtrWrapper> q(100);
651 std::unique_ptr<int> p { new int(123) };
652 q.emplace(std::move(p));
653 UniquePtrWrapper item;
654 ASSERT_OR_FAIL(q.try_dequeue(item));
655 ASSERT_OR_FAIL(item.get_value() == 123);
656 ASSERT_OR_FAIL(q.size_approx() == 0);
657
658 return true;
659 }
660
661 // This is what you have to do to try_enqueue() a movable type, and demonstrates why try_emplace() is useful
662 bool try_enqueue_fail_workaround()

Callers 2

blockingMethod · 0.80

Calls 3

get_valueMethod · 0.80
try_dequeueMethod · 0.45
size_approxMethod · 0.45

Tested by

no test coverage detected