Skip to content

Commit 3d762bd

Browse files
committed
CI
1 parent 7246f62 commit 3d762bd

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

libcxx/include/__flat_map/flat_map.h

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ class flat_map {
8484

8585
public:
8686
// types
87-
using key_type = _Key;
88-
using mapped_type = _Tp;
89-
using value_type = pair<key_type, mapped_type>;
90-
using key_compare = __type_identity_t<_Compare>;
91-
using reference = pair<const key_type&, mapped_type&>;
92-
using const_reference = pair<const key_type&, const mapped_type&>;
87+
using key_type = _Key;
88+
using mapped_type = _Tp;
89+
using value_type = pair<key_type, mapped_type>;
90+
using key_compare = __type_identity_t<_Compare>;
91+
using reference = pair<const key_type&, mapped_type&>;
92+
using const_reference = pair<const key_type&, const mapped_type&>;
9393
using size_type = size_t;
9494
using difference_type = ptrdiff_t;
9595
using iterator = __iterator<false>; // see [container.requirements]
@@ -252,16 +252,23 @@ class flat_map {
252252
// state if an exception is thrown.
253253
_LIBCPP_HIDE_FROM_ABI flat_map(const flat_map&) = default;
254254

255-
_LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other) noexcept(
256-
is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> &&
257-
is_nothrow_move_constructible_v<_Compare>) try
255+
// gcc does not like the `throw` keyword in a conditional noexcept function
256+
// split the move constructor into two
257+
_LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other) try
258258
: __containers_(std::move(__other.__containers_)), __compare_(std::move(__other.__compare_)) {
259259
__other.clear();
260260
} catch (...) {
261261
__other.clear();
262262
throw;
263263
}
264264

265+
_LIBCPP_HIDE_FROM_ABI flat_map(flat_map&& __other) noexcept
266+
requires is_nothrow_move_constructible_v<_KeyContainer> && is_nothrow_move_constructible_v<_MappedContainer> &&
267+
is_nothrow_move_constructible_v<_Compare>
268+
: __containers_(std::move(__other.__containers_)), __compare_(std::move(__other.__compare_)) {
269+
__other.clear();
270+
}
271+
265272
template <class _Allocator>
266273
requires __allocator_ctor_constraint<_Allocator>
267274
_LIBCPP_HIDE_FROM_ABI flat_map(const flat_map& __other, const _Allocator& __alloc)
@@ -590,8 +597,6 @@ class flat_map {
590597
// [flat.map.modifiers], modifiers
591598
template <class... _Args>
592599
requires is_constructible_v<pair<key_type, mapped_type>, _Args...>
593-
// todo: LWG
594-
// insufficiently constrained. key and values need to be move constructible
595600
_LIBCPP_HIDE_FROM_ABI pair<iterator, bool> emplace(_Args&&... __args) {
596601
std::pair<key_type, mapped_type> __pair(std::forward<_Args>(__args)...);
597602
return __try_emplace(std::move(__pair.first), std::move(__pair.second));
@@ -809,7 +814,6 @@ class flat_map {
809814
_LIBCPP_HIDE_FROM_ABI key_compare key_comp() const { return __compare_; }
810815
_LIBCPP_HIDE_FROM_ABI value_compare value_comp() const { return value_compare(__compare_); }
811816

812-
// todo: can flat_map | std::views::keys be specialised?
813817
_LIBCPP_HIDE_FROM_ABI const key_container_type& keys() const noexcept { return __containers_.keys; }
814818
_LIBCPP_HIDE_FROM_ABI const mapped_container_type& values() const noexcept { return __containers_.values; }
815819

@@ -841,7 +845,6 @@ class flat_map {
841845
_LIBCPP_HIDE_FROM_ABI bool contains(const key_type& __x) const { return find(__x) != end(); }
842846

843847
template <class _Kp>
844-
// todo: spec does not say about transparent for this one. LWG issue?
845848
requires __is_compare_transparent
846849
_LIBCPP_HIDE_FROM_ABI bool contains(const _Kp& __x) const {
847850
return find(__x) != end();
@@ -922,6 +925,7 @@ class flat_map {
922925
};
923926

924927
template <class _Allocator, class _KeyCont, class _MappedCont, class... _CompArg>
928+
requires __allocator_ctor_constraint<_Allocator>
925929
_LIBCPP_HIDE_FROM_ABI
926930
flat_map(__ctor_uses_allocator_tag,
927931
const _Allocator& __alloc,
@@ -935,6 +939,7 @@ class flat_map {
935939
__compare_(std::forward<_CompArg>(__comp)...) {}
936940

937941
template <class _Allocator, class... _CompArg>
942+
requires __allocator_ctor_constraint<_Allocator>
938943
_LIBCPP_HIDE_FROM_ABI flat_map(__ctor_uses_allocator_empty_tag, const _Allocator& __alloc, _CompArg&&... __comp)
939944
: __containers_{.keys = std::make_obj_using_allocator<key_container_type>(__alloc),
940945
.values = std::make_obj_using_allocator<mapped_container_type>(__alloc)},
@@ -1183,8 +1188,6 @@ class flat_map {
11831188
struct __key_equiv {
11841189
_LIBCPP_HIDE_FROM_ABI __key_equiv(key_compare __c) : __comp_(__c) {}
11851190
_LIBCPP_HIDE_FROM_ABI bool operator()(const_reference __x, const_reference __y) const {
1186-
// todo
1187-
// LWG issue ? spec uses __x.first but zip_view no longer uses pair
11881191
return !__comp_(std::get<0>(__x), std::get<0>(__y)) && !__comp_(std::get<0>(__y), std::get<0>(__x));
11891192
}
11901193
key_compare __comp_;

libcxx/modules/std.cppm.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ module;
6464
#include <execution>
6565
#include <expected>
6666
#include <filesystem>
67+
#include <flat_map>
6768
#include <format>
6869
#include <forward_list>
6970
#if !defined(_LIBCPP_HAS_NO_LOCALIZATION)

0 commit comments

Comments
 (0)