diff --git a/include/momo/stdish/set.h b/include/momo/stdish/set.h index ff19365bc..39c252083 100644 --- a/include/momo/stdish/set.h +++ b/include/momo/stdish/set.h @@ -474,6 +474,15 @@ class set return { res.position, res.inserted }; } + template + momo::internal::EnableIf::type>::value, + std::pair> emplace(ValueArg&& valueArg) + { + typename TreeSet::InsertResult res = mTreeSet.InsertVar( + static_cast(valueArg), std::forward(valueArg)); + return { res.position, res.inserted }; + } + template iterator emplace_hint(const_iterator hint, ValueArgs&&... valueArgs) { @@ -486,6 +495,15 @@ class set return mTreeSet.Add(hint, std::move(extItem)); } + template + momo::internal::EnableIf::type>::value, + iterator> emplace_hint(const_iterator hint, ValueArg&& valueArg) + { + if (!pvCheckHint(hint, static_cast(valueArg))) + return emplace(std::forward(valueArg)).first; + return mTreeSet.AddVar(hint, std::forward(valueArg)); + } + iterator erase(const_iterator where) { return mTreeSet.Remove(where); diff --git a/test/sources/libcxx/multiset/emplace_hint.pass.cpp b/test/sources/libcxx/multiset/emplace_hint.pass.cpp index a95157b9e..1ab5c8f8a 100644 --- a/test/sources/libcxx/multiset/emplace_hint.pass.cpp +++ b/test/sources/libcxx/multiset/emplace_hint.pass.cpp @@ -78,6 +78,10 @@ void main() assert(r == m.begin()); assert(m.size() == 1); assert(*r == 2); + r = m.emplace_hint(m.cend(), M::value_type(1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(*r == 1); } #ifdef LIBCPP_TEST_MIN_ALLOCATOR {