| 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() |
no test coverage detected