flat_foo constructors taking KeyContainer lack KeyCompare parameter
[flat.map][flat.multimap] [flat.set][flat.multiset]
Arthur O'Dwyer

Created on 2022-10-25.00:00:00 last changed 1 month ago


Date: 2022-11-15.00:00:00

[ 2022-11-04; Reflector poll ]

Set priority to 1 after reflector poll.

Date: 2022-10-30.10:44:58

flat_set's current constructor overload set has these two overloads:

explicit flat_set(container_type cont);
template<class Allocator>
  flat_set(const container_type& cont, const Allocator& a);

I believe it should have these two in addition:

flat_set(const key_compare& comp, container_type cont);
template<class Allocator>
  flat_set(const key_compare& comp, const container_type& cont, const Allocator& a);

with corresponding deduction guides. Similar wording changes would have to be made to all the flat_foo containers.

Tony Table:

struct LessWhenDividedBy {
  int divisor_;
  bool operator()(int x, int y) const { return x/divisor_ < y/divisor_; }
std::flat_set<int, LessWhenDividedBy> s(data.begin(), data.end(), LessWhenDividedBy(10));
// BEFORE AND AFTER: okay, but cumbersome
std::flat_set<int, LessWhenDividedBy> s(data);
// BEFORE AND AFTER: oops, this default-constructs the comparator

std::flat_set<int, LessWhenDividedBy> s(LessWhenDividedBy(10), data);
// BEFORE: fails to compile
// AFTER: compiles successfully
Date User Action Args
2022-11-04 20:59:04adminsetmessages: + msg12922
2022-10-25 00:00:00admincreate