https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78595

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
And for the insert-with-hint case:

@@ -848,13 +855,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       { return _M_t._M_insert_unique_(__position, __x); }

 #if __cplusplus >= 201103L
-      template<typename _Pair, typename = typename
-              std::enable_if<std::is_constructible<value_type,
-                                                   _Pair&&>::value>::type>
+      iterator
+      insert(const_iterator __position, value_type&& __x)
+      { return _M_t._M_insert_unique_(__position, std::move(__x)); }
+
+      template<typename _Pair, typename = _Insertable<_Pair>>
         iterator
         insert(const_iterator __position, _Pair&& __x)
-        { return _M_t._M_insert_unique_(__position,
-                                       std::forward<_Pair>(__x)); }
+        { return _M_t._M_insert_unique_(__position, value_type(__x)); }
 #endif

       /**

We could do something similar for multimap, but it would still involve an
unnecessary move when we do the insertion. That would be an improvement on what
we have today, but the optimal case would totally refactor _M_insert_equal* to
allocate a node immediately, construct into it, get the insert position, then
hook the node in at the right position. That's complicated, and definitely not
stage 3 material.

Reply via email to