Skip to content

Commit abbb226

Browse files
committed
P3567R2 flat_meow fixes
1 parent 5e49eff commit abbb226

File tree

2 files changed

+149
-23
lines changed

2 files changed

+149
-23
lines changed

source/containers.tex

Lines changed: 147 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17033,7 +17033,9 @@
1703317033

1703417034
\pnum
1703517035
If any member function in \ref{flat.map.defn} exits via an exception
17036-
the invariants are restored.
17036+
the invariants of the object argument are restored.
17037+
For the move constructor and move assignment operator,
17038+
the invariants of both arguments are restored.
1703717039
\begin{note}
1703817040
This can result in the \tcode{flat_map} being emptied.
1703917041
\end{note}
@@ -17118,6 +17120,11 @@
1711817120
// \ref{flat.map.cons}, constructors
1711917121
constexpr flat_map() : flat_map(key_compare()) { }
1712017122

17123+
flat_map(const flat_map&);
17124+
flat_map(flat_map&&);
17125+
flat_map& operator=(const flat_map&);
17126+
flat_map& operator=(flat_map&&);
17127+
1712117128
constexpr explicit flat_map(const key_compare& comp)
1712217129
: @\exposid{c}@(), @\exposid{compare}@(comp) { }
1712317130

@@ -17258,6 +17265,8 @@
1725817265
constexpr void insert(sorted_unique_t, InputIterator first, InputIterator last);
1725917266
template<@\exposconcept{container-compatible-range}@<value_type> R>
1726017267
constexpr void insert_range(R&& rg);
17268+
template<@\exposconcept{container-compatible-range}@<value_type> R>
17269+
void insert_range(sorted_unique_t, R&& rg);
1726117270

1726217271
constexpr void insert(initializer_list<value_type> il)
1726317272
{ insert(il.begin(), il.end()); }
@@ -17298,7 +17307,7 @@
1729817307
template<class K> constexpr size_type erase(K&& x);
1729917308
constexpr iterator erase(const_iterator first, const_iterator last);
1730017309

17301-
constexpr void swap(flat_map& y) noexcept;
17310+
constexpr void swap(flat_map& y) noexcept(@\seebelow@);
1730217311
constexpr void clear() noexcept;
1730317312

1730417313
// observers
@@ -17341,7 +17350,7 @@
1734117350
friend constexpr @\exposid{synth-three-way-result}@<value_type>
1734217351
operator<=>(const flat_map& x, const flat_map& y);
1734317352

17344-
friend constexpr void swap(flat_map& x, flat_map& y) noexcept
17353+
friend constexpr void swap(flat_map& x, flat_map& y) noexcept(noexcept(x.swap(y)))
1734517354
{ x.swap(y); }
1734617355

1734717356
private:
@@ -17816,10 +17825,10 @@
1781617825
\effects
1781717826
Adds elements to \exposid{c} as if by:
1781817827
\begin{codeblock}
17819-
for (const auto& e : rg) {
17820-
@\exposid{c}@.keys.insert(@\exposid{c}@.keys.end(), e.first);
17821-
@\exposid{c}@.values.insert(@\exposid{c}@.values.end(), e.second);
17822-
}
17828+
ranges::for_each(rg, [&](value_type e) {
17829+
@\exposid{c}@.keys.insert(@\exposid{c}@.keys.end(), std::move(e.first));
17830+
@\exposid{c}@.values.insert(@\exposid{c}@.values.end(), std::move(e.second));
17831+
});
1782317832
\end{codeblock}
1782417833
Then, sorts the range of newly inserted elements
1782517834
with respect to \tcode{value_comp()};
@@ -17845,6 +17854,22 @@
1784517854
Since this operation performs an in-place merge, it may allocate memory.
1784617855
\end{itemdescr}
1784717856

17857+
\indexlibrarymember{insert_range}{flat_map}%
17858+
\begin{itemdecl}
17859+
template<@\exposconcept{container-compatible-range}@<value_type> R>
17860+
void insert_range(sorted_unique_t, R&& rg);
17861+
\end{itemdecl}
17862+
17863+
\begin{itemdescr}
17864+
\pnum
17865+
\effects
17866+
Equivalent to \tcode{insert_range(rg)}.
17867+
17868+
\pnum
17869+
\complexity
17870+
Linear in $N$, where $N$ is \tcode{size()} after the operation.
17871+
\end{itemdescr}
17872+
1784817873
\indexlibrarymember{try_emplace}{flat_map}%
1784917874
\begin{itemdecl}
1785017875
template<class... Args>
@@ -18047,7 +18072,10 @@
1804718072

1804818073
\indexlibrarymember{swap}{flat_map}%
1804918074
\begin{itemdecl}
18050-
constexpr void swap(flat_map& y) noexcept;
18075+
constexpr void swap(flat_map& y)
18076+
noexcept(is_nothrow_swappable_v<key_container_type> &&
18077+
is_nothrow_swappable_v<mapped_container_type> &&
18078+
is_nothrow_swappable_v<key_compare>);
1805118079
\end{itemdecl}
1805218080

1805318081
\begin{itemdescr}
@@ -18209,7 +18237,9 @@
1820918237

1821018238
\pnum
1821118239
If any member function in \ref{flat.multimap.defn} exits via an exception,
18212-
the invariants are restored.
18240+
the invariants of the object argument are restored.
18241+
For the move constructor and move assignment operator,
18242+
the invariants of both arguments are restored.
1821318243
\begin{note}
1821418244
This can result in the \tcode{flat_multimap} being emptied.
1821518245
\end{note}
@@ -18292,6 +18322,11 @@
1829218322
// \ref{flat.multimap.cons}, constructors
1829318323
constexpr flat_multimap() : flat_multimap(key_compare()) { }
1829418324

18325+
flat_multimap(const flat_multimap&);
18326+
flat_multimap(flat_multimap&&);
18327+
flat_multimap& operator=(const flat_multimap&);
18328+
flat_multimap& operator=(flat_multimap&&);
18329+
1829518330
constexpr explicit flat_multimap(const key_compare& comp)
1829618331
: @\exposid{c}@(), @\exposid{compare}@(comp) { }
1829718332

@@ -18425,6 +18460,8 @@
1842518460
constexpr void insert(sorted_equivalent_t, InputIterator first, InputIterator last);
1842618461
template<@\exposconcept{container-compatible-range}@<value_type> R>
1842718462
constexpr void insert_range(R&& rg);
18463+
template<@\exposconcept{container-compatible-range}@<value_type> R>
18464+
void insert_range(sorted_unique_t, R&& rg);
1842818465

1842918466
constexpr void insert(initializer_list<value_type> il)
1843018467
{ insert(il.begin(), il.end()); }
@@ -18440,7 +18477,10 @@
1844018477
template<class K> constexpr size_type erase(K&& x);
1844118478
constexpr iterator erase(const_iterator first, const_iterator last);
1844218479

18443-
constexpr void swap(flat_multimap&) noexcept;
18480+
constexpr void swap(flat_multimap&)
18481+
noexcept(is_nothrow_swappable_v<key_container_type> &&
18482+
is_nothrow_swappable_v<mapped_container_type> &&
18483+
is_nothrow_swappable_v<key_compare>);
1844418484
constexpr void clear() noexcept;
1844518485

1844618486
// observers
@@ -18484,7 +18524,8 @@
1848418524
friend constexpr @\exposid{synth-three-way-result}@<value_type>
1848518525
operator<=>(const flat_multimap& x, const flat_multimap& y);
1848618526

18487-
friend constexpr void swap(flat_multimap& x, flat_multimap& y) noexcept
18527+
friend constexpr void swap(flat_multimap& x, flat_multimap& y)
18528+
noexcept(noexcept(x.swap(y)))
1848818529
{ x.swap(y); }
1848918530

1849018531
private:
@@ -18852,7 +18893,9 @@
1885218893

1885318894
\pnum
1885418895
If any member function in \ref{flat.set.defn} exits via an exception,
18855-
the invariant is restored.
18896+
the invariant of the object argument is restored.
18897+
For the move constructor and move assignment operator,
18898+
the invariants of both arguments are restored.
1885618899
\begin{note}
1885718900
This can result in the \tcode{flat_set}'s being emptied.
1885818901
\end{note}
@@ -18906,6 +18949,11 @@
1890618949
// \ref{flat.set.cons}, constructors
1890718950
constexpr flat_set() : flat_set(key_compare()) { }
1890818951

18952+
flat_set(const flat_set&);
18953+
flat_set(flat_set&&);
18954+
flat_set& operator=(const flat_set&);
18955+
flat_set& operator=(flat_set&&);
18956+
1890918957
constexpr explicit flat_set(const key_compare& comp)
1891018958
: @\exposid{c}@(), @\exposid{compare}@(comp) { }
1891118959

@@ -19031,6 +19079,8 @@
1903119079
constexpr void insert(sorted_unique_t, InputIterator first, InputIterator last);
1903219080
template<@\exposconcept{container-compatible-range}@<value_type> R>
1903319081
constexpr void insert_range(R&& rg);
19082+
template<@\exposconcept{container-compatible-range}@<value_type> R>
19083+
void insert_range(sorted_unique_t, R&& rg);
1903419084

1903519085
constexpr void insert(initializer_list<value_type> il)
1903619086
{ insert(il.begin(), il.end()); }
@@ -19359,9 +19409,9 @@
1935919409
\effects
1936019410
Adds elements to \exposid{c} as if by:
1936119411
\begin{codeblock}
19362-
for (const auto& e : rg) {
19363-
@\exposid{c}@.insert(@\exposid{c}@.end(), e);
19364-
}
19412+
ranges::for_each(rg, [&](auto&& e) {
19413+
@\exposid{c}@.insert(@\exposid{c}@.end(), std::forward<decltype(e)>(e));
19414+
});
1936519415
\end{codeblock}
1936619416
Then,
1936719417
sorts the range of newly inserted elements with respect to \exposid{compare};
@@ -19380,9 +19430,27 @@
1938019430
Since this operation performs an in-place merge, it may allocate memory.
1938119431
\end{itemdescr}
1938219432

19433+
\indexlibrarymember{insert_range}{flat_set}%
19434+
\begin{itemdecl}
19435+
template<@\exposconcept{container-compatible-range}@<value_type> R>
19436+
void insert_range(sorted_unique_t, R&& rg);
19437+
\end{itemdecl}
19438+
19439+
\begin{itemdescr}
19440+
\pnum
19441+
\effects
19442+
Equivalent to \tcode{insert_range(rg)}.
19443+
19444+
\pnum
19445+
\complexity
19446+
Linear in $N$, where $N$ is \tcode{size()} after the operation.
19447+
\end{itemdescr}
19448+
1938319449
\indexlibrarymember{swap}{flat_set}%
1938419450
\begin{itemdecl}
19385-
constexpr void swap(flat_set& y) noexcept;
19451+
constexpr void swap(flat_set& y)
19452+
noexcept(is_nothrow_swappable_v<container_type> &&
19453+
is_nothrow_swappable_v<key_compare>);
1938619454
\end{itemdecl}
1938719455

1938819456
\begin{itemdescr}
@@ -19522,7 +19590,9 @@
1952219590

1952319591
\pnum
1952419592
If any member function in \ref{flat.multiset.defn} exits via an exception,
19525-
the invariant is restored.
19593+
the invariant of the object argument is restored.
19594+
For the move constructor and move assignment operator,
19595+
the invariants of both arguments are restored.
1952619596
\begin{note}
1952719597
This can result in the \tcode{flat_multiset}'s being emptied.
1952819598
\end{note}
@@ -19575,6 +19645,11 @@
1957519645
// \ref{flat.multiset.cons}, constructors
1957619646
constexpr flat_multiset() : flat_multiset(key_compare()) { }
1957719647

19648+
flat_multiset(const flat_multiset&);
19649+
flat_multiset(flat_multiset&&);
19650+
flat_multiset& operator=(const flat_multiset&);
19651+
flat_multiset& operator=(flat_multiset&&);
19652+
1957819653
constexpr explicit flat_multiset(const key_compare& comp)
1957919654
: @\exposid{c}@(), @\exposid{compare}@(comp) { }
1958019655

@@ -19702,6 +19777,8 @@
1970219777
constexpr void insert(sorted_equivalent_t, InputIterator first, InputIterator last);
1970319778
template<@\exposconcept{container-compatible-range}@<value_type> R>
1970419779
constexpr void insert_range(R&& rg);
19780+
template<@\exposconcept{container-compatible-range}@<value_type> R>
19781+
void insert_range(sorted_unique_t, R&& rg);
1970519782

1970619783
constexpr void insert(initializer_list<value_type> il)
1970719784
{ insert(il.begin(), il.end()); }
@@ -19717,7 +19794,7 @@
1971719794
template<class K> constexpr size_type erase(K&& x);
1971819795
constexpr iterator erase(const_iterator first, const_iterator last);
1971919796

19720-
constexpr void swap(flat_multiset& y) noexcept;
19797+
constexpr void swap(flat_multiset& y) noexcept(@\seebelow@);
1972119798
constexpr void clear() noexcept;
1972219799

1972319800
// observers
@@ -19758,7 +19835,8 @@
1975819835
friend constexpr @\exposid{synth-three-way-result}@<value_type>
1975919836
operator<=>(const flat_multiset& x, const flat_multiset& y);
1976019837

19761-
friend constexpr void swap(flat_multiset& x, flat_multiset& y) noexcept
19838+
friend constexpr void swap(flat_multiset& x, flat_multiset& y)
19839+
noexcept(noexcept(x.swap(y)))
1976219840
{ x.swap(y); }
1976319841

1976419842
private:
@@ -20005,12 +20083,60 @@
2000520083

2000620084
\pnum
2000720085
\complexity
20008-
Linear.
20086+
Linear in $N$, where $N$ is \tcode{size()} after the operation.
20087+
\end{itemdescr}
20088+
20089+
\indexlibrarymember{insert_range}{flat_multiset}%
20090+
\begin{itemdecl}
20091+
template<@\exposconcept{container-compatible-range}@<value_type> R>
20092+
void insert_range(R&& rg);
20093+
\end{itemdecl}
20094+
20095+
\begin{itemdescr}
20096+
\pnum
20097+
\effects
20098+
Adds elements to \exposid{c} as if by:
20099+
\begin{codeblock}
20100+
ranges::for_each(rg, [&](auto&& e) {
20101+
@\exposid{c}@.insert(@\exposid{c}@.end(), std::forward<decltype(e)>(e));
20102+
});
20103+
\end{codeblock}
20104+
Then, sorts the range of newly inserted elements with respect to \exposid{compare},
20105+
and merges the resulting sorted range and
20106+
the sorted range of pre-existing elements into a single sorted range.
20107+
20108+
\pnum
20109+
\complexity
20110+
$N$ + $M \log M$, where $N$ is \tcode{size()} before the operation and $M$
20111+
is \tcode{ranges::distance(rg)}.
20112+
20113+
\pnum
20114+
\remarks
20115+
Since this operation performs an in-place merge,
20116+
it may allocate memory.
20117+
\end{itemdescr}
20118+
20119+
\indexlibrarymember{insert_range}{flat_multiset}%
20120+
\begin{itemdecl}
20121+
template<@\exposconcept{container-compatible-range}@<value_type> R>
20122+
void insert_range(sorted_unique_t, R&& rg);
20123+
\end{itemdecl}
20124+
20125+
\begin{itemdescr}
20126+
\pnum
20127+
\effects
20128+
Equivalent to \tcode{insert_range(rg)}.
20129+
20130+
\pnum
20131+
\complexity
20132+
Linear in $N$, where $N$ is \tcode{size()} after the operation.
2000920133
\end{itemdescr}
2001020134

2001120135
\indexlibrarymember{swap}{flat_multiset}%
2001220136
\begin{itemdecl}
20013-
constexpr void swap(flat_multiset& y) noexcept;
20137+
constexpr void swap(flat_multiset& y)
20138+
noexcept(is_nothrow_swappable_v<container_type> &&
20139+
is_nothrow_swappable_v<key_compare>);
2001420140
\end{itemdecl}
2001520141

2001620142
\begin{itemdescr}

source/support.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,8 +673,8 @@
673673
#define @\defnlibxname{cpp_lib_execution}@ 201902L // also in \libheader{execution}
674674
#define @\defnlibxname{cpp_lib_expected}@ 202211L // also in \libheader{expected}
675675
#define @\defnlibxname{cpp_lib_filesystem}@ 201703L // also in \libheader{filesystem}
676-
#define @\defnlibxname{cpp_lib_flat_map}@ 202207L // also in \libheader{flat_map}
677-
#define @\defnlibxname{cpp_lib_flat_set}@ 202207L // also in \libheader{flat_set}
676+
#define @\defnlibxname{cpp_lib_flat_map}@ 202511L // also in \libheader{flat_map}
677+
#define @\defnlibxname{cpp_lib_flat_set}@ 202511L // also in \libheader{flat_set}
678678
#define @\defnlibxname{cpp_lib_format}@ 202311L // also in \libheader{format}
679679
#define @\defnlibxname{cpp_lib_format_path}@ 202506L // also in \libheader{filesystem}
680680
#define @\defnlibxname{cpp_lib_format_ranges}@ 202207L // also in \libheader{format}

0 commit comments

Comments
 (0)