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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The way our flat_set::emplace is implemented, it always constructs an object on
the stack:

      template<typename... _Args>
        pair<iterator, bool>
        _M_try_emplace(optional<const_iterator> __hint, _Args&&... __args)
        {
          // TODO: Simplify and audit the hint handling.
          value_type __k(std::forward<_Args>(__args)...);

We should optimize that to avoid constructing a new object when
sizeof...(_Args)==1 and same_as<remove_cvref_t<_Args...[0]>, value_type>.

Reply via email to