Skip to content

Commit ea393ab

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

File tree

2 files changed

+151
-24
lines changed

2 files changed

+151
-24
lines changed

source/containers.tex

Lines changed: 149 additions & 22 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_equivalent_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()); }
@@ -19087,7 +19137,8 @@
1908719137
friend constexpr @\exposid{synth-three-way-result}@<value_type>
1908819138
operator<=>(const flat_set& x, const flat_set& y);
1908919139

19090-
friend constexpr void swap(flat_set& x, flat_set& y) noexcept { x.swap(y); }
19140+
friend constexpr void swap(flat_set& x, flat_set& y) noexcept(noexcept(x.swap(y)))
19141+
{ x.swap(y); }
1909119142

1909219143
private:
1909319144
container_type @\exposidnc{c}@; // \expos
@@ -19359,9 +19410,9 @@
1935919410
\effects
1936019411
Adds elements to \exposid{c} as if by:
1936119412
\begin{codeblock}
19362-
for (const auto& e : rg) {
19363-
@\exposid{c}@.insert(@\exposid{c}@.end(), e);
19364-
}
19413+
ranges::for_each(rg, [&](auto&& e) {
19414+
@\exposid{c}@.insert(@\exposid{c}@.end(), std::forward<decltype(e)>(e));
19415+
});
1936519416
\end{codeblock}
1936619417
Then,
1936719418
sorts the range of newly inserted elements with respect to \exposid{compare};
@@ -19380,9 +19431,27 @@
1938019431
Since this operation performs an in-place merge, it may allocate memory.
1938119432
\end{itemdescr}
1938219433

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

1938819457
\begin{itemdescr}
@@ -19522,7 +19591,9 @@
1952219591

1952319592
\pnum
1952419593
If any member function in \ref{flat.multiset.defn} exits via an exception,
19525-
the invariant is restored.
19594+
the invariant of the object argument is restored.
19595+
For the move constructor and move assignment operator,
19596+
the invariants of both arguments are restored.
1952619597
\begin{note}
1952719598
This can result in the \tcode{flat_multiset}'s being emptied.
1952819599
\end{note}
@@ -19575,6 +19646,11 @@
1957519646
// \ref{flat.multiset.cons}, constructors
1957619647
constexpr flat_multiset() : flat_multiset(key_compare()) { }
1957719648

19649+
flat_multiset(const flat_multiset&);
19650+
flat_multiset(flat_multiset&&);
19651+
flat_multiset& operator=(const flat_multiset&);
19652+
flat_multiset& operator=(flat_multiset&&);
19653+
1957819654
constexpr explicit flat_multiset(const key_compare& comp)
1957919655
: @\exposid{c}@(), @\exposid{compare}@(comp) { }
1958019656

@@ -19702,6 +19778,8 @@
1970219778
constexpr void insert(sorted_equivalent_t, InputIterator first, InputIterator last);
1970319779
template<@\exposconcept{container-compatible-range}@<value_type> R>
1970419780
constexpr void insert_range(R&& rg);
19781+
template<@\exposconcept{container-compatible-range}@<value_type> R>
19782+
void insert_range(sorted_equivalent_t, R&& rg);
1970519783

1970619784
constexpr void insert(initializer_list<value_type> il)
1970719785
{ insert(il.begin(), il.end()); }
@@ -19717,7 +19795,7 @@
1971719795
template<class K> constexpr size_type erase(K&& x);
1971819796
constexpr iterator erase(const_iterator first, const_iterator last);
1971919797

19720-
constexpr void swap(flat_multiset& y) noexcept;
19798+
constexpr void swap(flat_multiset& y) noexcept(@\seebelow@);
1972119799
constexpr void clear() noexcept;
1972219800

1972319801
// observers
@@ -19758,7 +19836,8 @@
1975819836
friend constexpr @\exposid{synth-three-way-result}@<value_type>
1975919837
operator<=>(const flat_multiset& x, const flat_multiset& y);
1976019838

19761-
friend constexpr void swap(flat_multiset& x, flat_multiset& y) noexcept
19839+
friend constexpr void swap(flat_multiset& x, flat_multiset& y)
19840+
noexcept(noexcept(x.swap(y)))
1976219841
{ x.swap(y); }
1976319842

1976419843
private:
@@ -20005,12 +20084,60 @@
2000520084

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

2001120136
\indexlibrarymember{swap}{flat_multiset}%
2001220137
\begin{itemdecl}
20013-
constexpr void swap(flat_multiset& y) noexcept;
20138+
constexpr void swap(flat_multiset& y)
20139+
noexcept(is_nothrow_swappable_v<container_type> &&
20140+
is_nothrow_swappable_v<key_compare>);
2001420141
\end{itemdecl}
2001520142

2001620143
\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)