https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119620
Bug ID: 119620
Summary: flat_set::emplace is constrained
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: hewillk at gmail dot com
Target Milestone: ---
This might be seen as *asking for trouble* bug report:
Currently, in libstdc++, flat_set::emplace requires
is_constructible_v<value_type, _Args...>, which is not required by the
standard.
https://godbolt.org/z/4q8hYssao
#include <flat_set>
template<class C>
concept can_emplace_str = requires (C& c) {
c.emplace(" ");
};
static_assert(can_emplace_str<std::flat_set<int>>);
It is worth noting that flat_multiset::emplace is constrained through.
I don't know why the standard sometimes constrains emplace(), sometimes only
constrains insert(), and sometimes constrains neither.
It seems to me that we should always require is_constructible_v<value_type,
Args...> or is_constructible_v<value_type, P&&> for both functions instead of
just Preconditions?
Since those hard errors are always annoying as it's pointed out in LWG 4121.