Reject `vector<bool>` and deduplicate mechanisms for `flat_meow` (#5045)

Co-authored-by: Casey Carter <cacarter@microsoft.com>
Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
This commit is contained in:
A. Jiang 2024-10-29 21:58:58 +08:00 коммит произвёл GitHub
Родитель c819e49476
Коммит 027f330670
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
3 изменённых файлов: 90 добавлений и 92 удалений

Просмотреть файл

@ -28,10 +28,6 @@ _STL_DISABLE_CLANG_WARNINGS
#undef new
_STD_BEGIN
template <class _Alloc, class _Key_container, class _Mapped_container>
concept _Valid_allocator_for_flat_map =
uses_allocator_v<_Key_container, _Alloc> && uses_allocator_v<_Mapped_container, _Alloc>;
template <class _Compare, class _Key_container>
concept _Valid_compare_for_container = is_invocable_v<const _Compare&, const typename _Key_container::value_type&,
const typename _Key_container::value_type&>;
@ -59,18 +55,6 @@ struct _Flat_map_container_provider {
};
};
template <class _Ty>
struct _NODISCARD _Clear_flat_map_scope_guard {
_Ty* _Clearable;
_Clear_flat_map_scope_guard(_Ty* _Clearable) : _Clearable(_Clearable) {}
~_Clear_flat_map_scope_guard() {
if (_Clearable) {
_Clearable->clear();
}
}
};
// Implementation
template <bool _IsUnique, class _Key, class _Mapped, class _Compare, class _KeyContainer, class _MappedContainer>
@ -305,6 +289,8 @@ public:
"key_type should be the element type of key_container_type");
static_assert(is_same_v<mapped_type, typename mapped_container_type::value_type>,
"mapped_type should be the element type of mapped_container_type");
static_assert(!_Is_vector_bool<key_container_type> && !_Is_vector_bool<mapped_container_type>,
"vector<bool, A> cannot be adapted because it is not a sequence container.");
_STL_INTERNAL_STATIC_ASSERT(random_access_iterator<iterator>);
_STL_INTERNAL_STATIC_ASSERT(convertible_to<iterator, const_iterator>);
@ -317,10 +303,10 @@ public:
explicit _Flat_map_base(const key_compare& _Comp) : _Key_compare(_Comp), _Data() {}
_Flat_map_base() : _Flat_map_base(key_compare()) {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
explicit _Flat_map_base(const _Allocator& _Alloc) : _Flat_map_base(key_compare(), _Alloc) {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
explicit _Flat_map_base(const key_compare& _Comp, const _Allocator& _Alloc)
: _Key_compare(_Comp), _Data{.keys = _STD make_obj_using_allocator<key_container_type>(_Alloc),
.values = _STD make_obj_using_allocator<mapped_container_type>(_Alloc)} {}
@ -334,7 +320,7 @@ public:
}
}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(
const key_container_type& _Key_cont, const mapped_container_type& _Mapped_cont, const _Allocator& _Alloc)
: _Flat_map_base(_Sorted_t(), _Key_cont, _Mapped_cont, _Alloc) {
@ -344,7 +330,7 @@ public:
}
}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(const key_container_type& _Key_cont, const mapped_container_type& _Mapped_cont,
const key_compare& _Comp, const _Allocator& _Alloc)
: _Flat_map_base(_Sorted_t(), _Key_cont, _Mapped_cont, _Comp, _Alloc) {
@ -358,14 +344,14 @@ public:
const key_compare& _Comp = key_compare())
: _Key_compare(_Comp), _Data{.keys = _STD move(_Key_cont), .values = _STD move(_Mapped_cont)} {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(_Sorted_t, const key_container_type& _Key_cont, const mapped_container_type& _Mapped_cont,
const _Allocator& _Alloc)
: _Key_compare(key_compare()),
_Data{.keys = _STD make_obj_using_allocator<key_container_type>(_Alloc, _Key_cont),
.values = _STD make_obj_using_allocator<mapped_container_type>(_Alloc, _Mapped_cont)} {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(_Sorted_t, const key_container_type& _Key_cont, const mapped_container_type& _Mapped_cont,
const key_compare& _Comp, const _Allocator& _Alloc)
: _Key_compare(_Comp),
@ -379,7 +365,7 @@ public:
insert(_First, _Last);
}
template <class _InputIterator, _Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <class _InputIterator, _Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
requires _Is_iterator_v<_InputIterator>
_Flat_map_base(_InputIterator _First, _InputIterator _Last, const key_compare& _Comp, const _Allocator& _Alloc)
: _Flat_map_base(_Comp, _Alloc) {
@ -391,7 +377,7 @@ public:
: _Flat_map_base(_From_range, _STD forward<_Rng>(_Range), key_compare()) {}
template <_Container_compatible_range<value_type> _Rng,
_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(from_range_t _From_range, _Rng&& _Range, const _Allocator& _Alloc)
: _Flat_map_base(_From_range, _STD forward<_Rng>(_Range), key_compare(), _Alloc) {}
@ -401,7 +387,7 @@ public:
}
template <_Container_compatible_range<value_type> _Rng,
_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(from_range_t, _Rng&& _Range, const key_compare& _Comp, const _Allocator& _Alloc)
: _Flat_map_base(_Comp, _Alloc) {
insert_range(_STD forward<_Rng>(_Range));
@ -415,7 +401,7 @@ public:
insert(_Tag, _First, _Last);
}
template <class _InputIterator, _Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <class _InputIterator, _Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
requires _Is_iterator_v<_InputIterator>
_Flat_map_base(
_Sorted_t _Tag, _InputIterator _First, _InputIterator _Last, const key_compare& _Comp, const _Allocator& _Alloc)
@ -423,7 +409,7 @@ public:
insert(_Tag, _First, _Last);
}
template <class _InputIterator, _Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <class _InputIterator, _Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
requires _Is_iterator_v<_InputIterator>
_Flat_map_base(_Sorted_t _Tag, _InputIterator _First, _InputIterator _Last, const _Allocator& _Alloc)
: _Flat_map_base(_Tag, _First, _Last, key_compare(), _Alloc) {}
@ -431,23 +417,23 @@ public:
_Flat_map_base(initializer_list<value_type> _Ilist, const key_compare& _Comp = key_compare())
: _Flat_map_base(_Ilist.begin(), _Ilist.end(), _Comp) {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(initializer_list<value_type> _Ilist, const key_compare& _Comp, const _Allocator& _Alloc)
: _Flat_map_base(_Ilist.begin(), _Ilist.end(), _Comp, _Alloc) {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(initializer_list<value_type> _Ilist, const _Allocator& _Alloc)
: _Flat_map_base(_Ilist, key_compare(), _Alloc) {}
_Flat_map_base(_Sorted_t _Tag, initializer_list<value_type> _Ilist, const key_compare& _Comp = key_compare())
: _Flat_map_base(_Tag, _Ilist.begin(), _Ilist.end(), _Comp) {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(
_Sorted_t _Tag, initializer_list<value_type> _Ilist, const key_compare& _Comp, const _Allocator& _Alloc)
: _Flat_map_base(_Tag, _Ilist.begin(), _Ilist.end(), _Comp, _Alloc) {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(_Sorted_t _Tag, initializer_list<value_type> _Ilist, const _Allocator& _Alloc)
: _Flat_map_base(_Tag, _Ilist, key_compare(), _Alloc) {}
@ -456,7 +442,7 @@ public:
: _Key_compare(static_cast<const _Flat_map_base&>(_Other)._Key_compare),
_Data(static_cast<const _Flat_map_base&>(_Other)._Data) {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(const _Derived& _Other, const _Allocator& _Alloc)
: _Key_compare(static_cast<const _Flat_map_base&>(_Other)._Key_compare),
_Data{.keys = _STD make_obj_using_allocator<key_container_type>(
@ -471,7 +457,7 @@ public:
: _Key_compare(_STD move(static_cast<_Flat_map_base&>(_Other)._Key_compare)),
_Data(_STD move(static_cast<_Flat_map_base&>(_Other).extract())) {}
template <_Valid_allocator_for_flat_map<key_container_type, mapped_container_type> _Allocator>
template <_Usable_allocator_for<key_container_type, mapped_container_type> _Allocator>
_Flat_map_base(_Derived&& _Other, const _Allocator& _Alloc)
noexcept(is_nothrow_move_constructible_v<key_compare> && is_nothrow_move_constructible_v<key_container_type>
&& is_nothrow_move_constructible_v<mapped_container_type>)
@ -614,18 +600,18 @@ public:
}
iterator erase(const_iterator _Position) {
_Clear_flat_map_scope_guard _Guard{this};
auto _Key_it = _Data.keys.erase(_Position._Key_it);
auto _Val_it = _Data.values.erase(_Position._Mapped_it);
_Guard._Clearable = nullptr;
_Clear_guard _Guard{this};
auto _Key_it = _Data.keys.erase(_Position._Key_it);
auto _Val_it = _Data.values.erase(_Position._Mapped_it);
_Guard._Target = nullptr;
return iterator{_STD move(_Key_it), _STD move(_Val_it)};
}
iterator erase(const_iterator _First, const_iterator _Last) {
_Clear_flat_map_scope_guard _Guard{this};
auto _Key_it = _Data.keys.erase(_First._Key_it, _Last._Key_it);
auto _Val_it = _Data.values.erase(_First._Mapped_it, _Last._Mapped_it);
_Guard._Clearable = nullptr;
_Clear_guard _Guard{this};
auto _Key_it = _Data.keys.erase(_First._Key_it, _Last._Key_it);
auto _Val_it = _Data.values.erase(_First._Mapped_it, _Last._Mapped_it);
_Guard._Target = nullptr;
return iterator{_STD move(_Key_it), _STD move(_Val_it)};
}
@ -641,15 +627,15 @@ public:
}
containers extract() && {
_Clear_flat_map_scope_guard _Guard{this};
_Clear_guard _Guard{this};
return _STD move(_Data);
}
void replace(key_container_type&& _Key_cont, mapped_container_type&& _Mapped_cont) {
_Clear_flat_map_scope_guard _Guard{this};
_Data.keys = _STD move(_Key_cont);
_Data.values = _STD move(_Mapped_cont);
_Guard._Clearable = nullptr;
_Clear_guard _Guard{this};
_Data.keys = _STD move(_Key_cont);
_Data.values = _STD move(_Mapped_cont);
_Guard._Target = nullptr;
}
// observers
@ -809,13 +795,13 @@ protected:
auto _Mut_last = _View.end();
const auto _Old_size = size();
_Clear_flat_map_scope_guard<_Flat_map_base> _Guard{this};
_Clear_guard<_Flat_map_base> _Guard{this};
_STD _Seek_wrapped(_Mut_first, _RANGES remove_if(_View, _Pred).begin());
(void) _Data.keys.erase(_Mut_first._Key_it, _Mut_last._Key_it);
(void) _Data.values.erase(_Mut_first._Mapped_it, _Mut_last._Mapped_it);
_Guard._Clearable = nullptr;
_Guard._Target = nullptr;
return _Old_size - size();
}
@ -890,10 +876,10 @@ protected:
}
void _Insert_exact(const_iterator _Position, key_type&& _Key_val, mapped_type&& _Mapped_val) {
_Clear_flat_map_scope_guard _Guard{this};
_Clear_guard _Guard{this};
_Data.keys.insert(_Position._Key_it, _STD move(_Key_val));
_Data.values.insert(_Position._Mapped_it, _STD move(_Mapped_val));
_Guard._Clearable = nullptr;
_Guard._Target = nullptr;
}
template <class _KeyTy1, class _KeyTy2>
@ -915,13 +901,13 @@ private:
}
void _Sort() {
_Clear_flat_map_scope_guard _Guard{this};
_Clear_guard _Guard{this};
_RANGES sort(_View_to_mutate(), value_compare(_Key_compare));
_Guard._Clearable = nullptr;
_Guard._Target = nullptr;
}
void _Dedup() {
_Clear_flat_map_scope_guard _Guard{this};
_Clear_guard _Guard{this};
auto _Sorted_view = _View_to_mutate();
auto _Subrange = _RANGES unique(_Sorted_view, [this](const_reference _Left, const_reference _Right) {
return this->_Key_equal(_Left.first, _Right.first);
@ -929,13 +915,13 @@ private:
const auto _Remaining_count = _Subrange.begin() - _Sorted_view.begin();
_Data.keys.erase(_Data.keys.begin() + _Remaining_count, _Data.keys.end());
_Data.values.erase(_Data.values.begin() + _Remaining_count, _Data.values.end());
_Guard._Clearable = nullptr;
_Guard._Target = nullptr;
}
template <bool _NeedSorting, bool _NeedDeduping, class _InputIterator>
requires _Is_iterator_v<_InputIterator>
void _Insert_range(_InputIterator _First, _InputIterator _Last) {
_Clear_flat_map_scope_guard _Guard{this};
_Clear_guard _Guard{this};
const auto _Old_distance = static_cast<difference_type>(size());
@ -961,7 +947,7 @@ private:
_Dedup();
}
_Guard._Clearable = nullptr;
_Guard._Target = nullptr;
}
template <class _KeyTy>
@ -1312,13 +1298,13 @@ flat_map(_KeyContainer, _MappedContainer,
_Compare, _KeyContainer, _MappedContainer>;
template <class _KeyContainer, class _MappedContainer,
_Valid_allocator_for_flat_map<_KeyContainer, _MappedContainer> _Allocator>
_Usable_allocator_for<_KeyContainer, _MappedContainer> _Allocator>
flat_map(_KeyContainer, _MappedContainer,
_Allocator) -> flat_map<typename _KeyContainer::value_type, typename _MappedContainer::value_type,
less<typename _KeyContainer::value_type>, _KeyContainer, _MappedContainer>;
template <class _KeyContainer, class _MappedContainer, _Valid_compare_for_container<_KeyContainer> _Compare,
_Valid_allocator_for_flat_map<_KeyContainer, _MappedContainer> _Allocator>
_Usable_allocator_for<_KeyContainer, _MappedContainer> _Allocator>
flat_map(_KeyContainer, _MappedContainer, _Compare,
_Allocator) -> flat_map<typename _KeyContainer::value_type, typename _MappedContainer::value_type, _Compare,
_KeyContainer, _MappedContainer>;
@ -1330,13 +1316,13 @@ flat_map(sorted_unique_t, _KeyContainer, _MappedContainer,
_Compare, _KeyContainer, _MappedContainer>;
template <class _KeyContainer, class _MappedContainer,
_Valid_allocator_for_flat_map<_KeyContainer, _MappedContainer> _Allocator>
_Usable_allocator_for<_KeyContainer, _MappedContainer> _Allocator>
flat_map(sorted_unique_t, _KeyContainer, _MappedContainer,
_Allocator) -> flat_map<typename _KeyContainer::value_type, typename _MappedContainer::value_type,
less<typename _KeyContainer::value_type>, _KeyContainer, _MappedContainer>;
template <class _KeyContainer, class _MappedContainer, _Valid_compare_for_container<_KeyContainer> _Compare,
_Valid_allocator_for_flat_map<_KeyContainer, _MappedContainer> _Allocator>
_Usable_allocator_for<_KeyContainer, _MappedContainer> _Allocator>
flat_map(sorted_unique_t, _KeyContainer, _MappedContainer, _Compare,
_Allocator) -> flat_map<typename _KeyContainer::value_type, typename _MappedContainer::value_type, _Compare,
_KeyContainer, _MappedContainer>;

Просмотреть файл

@ -24,20 +24,6 @@ _STL_DISABLE_CLANG_WARNINGS
#undef new
_STD_BEGIN
template <class _Ty>
struct _NODISCARD _Clear_guard {
_Ty* _Target;
~_Clear_guard() {
if (_Target) {
_Target->clear();
}
}
};
template <class _Alloc, class _Container>
concept _Allocator_for = uses_allocator_v<_Container, _Alloc>;
template <class _Kty, class _Keylt, class _Container, bool _Multi, class _Deriv, class _Tsorted>
class _Base_flat_set {
private:
@ -47,6 +33,8 @@ public:
static_assert(same_as<_Kty, typename _Container::value_type>,
"The C++ Standard dictates that the Key type must be the "
"same as the container's value type [flatset.overview]");
static_assert(
!_Is_vector_bool<_Container>, "vector<bool, A> cannot be adapted because it is not a sequence container.");
using key_type = _Kty;
using value_type = _Kty;
@ -67,10 +55,10 @@ public:
_Base_flat_set() : _Mycont(), _Mycomp() {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(const _Deriv& _Set, const _Alloc& _Al)
: _Mycont(_STD make_obj_using_allocator<container_type>(_Al, _Set._Mycont)), _Mycomp(_Set._Mycomp) {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(_Deriv&& _Set, const _Alloc& _Al)
: _Mycont(_STD make_obj_using_allocator<container_type>(_Al, _STD move(_Set).extract())),
_Mycomp(_Set._Mycomp) // intentionally copy comparator, see LWG-2227
@ -80,10 +68,10 @@ public:
: _Mycont(_STD move(_Cont)), _Mycomp(_Comp) {
_Make_invariants_fulfilled();
}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(const container_type& _Cont, const _Alloc& _Al)
: _Base_flat_set(_STD make_obj_using_allocator<container_type>(_Al, _Cont)) {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(const container_type& _Cont, const key_compare& _Comp, const _Alloc& _Al)
: _Base_flat_set(_STD make_obj_using_allocator<container_type>(_Al, _Cont), _Comp) {}
@ -91,31 +79,31 @@ public:
: _Mycont(_STD move(_Cont)), _Mycomp(_Comp) {
_STL_ASSERT(_Is_sorted(_Mycont), _Msg_not_sorted);
}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(_Tsorted _Tsort, const container_type& _Cont, const _Alloc& _Al)
: _Base_flat_set(_Tsort, _STD make_obj_using_allocator<container_type>(_Al, _Cont)) {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(_Tsorted _Tsort, const container_type& _Cont, const key_compare& _Comp, const _Alloc& _Al)
: _Base_flat_set(_Tsort, _STD make_obj_using_allocator<container_type>(_Al, _Cont), _Comp) {}
explicit _Base_flat_set(const key_compare& _Comp) : _Mycont(), _Mycomp(_Comp) {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(const key_compare& _Comp, const _Alloc& _Al)
: _Mycont(_STD make_obj_using_allocator<container_type>(_Al)), _Mycomp(_Comp) {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
explicit _Base_flat_set(const _Alloc& _Al)
: _Mycont(_STD make_obj_using_allocator<container_type>(_Al)), _Mycomp() {}
template <input_iterator _Iter>
_Base_flat_set(_Iter _First, _Iter _Last, const key_compare& _Comp = key_compare())
: _Base_flat_set(container_type(_First, _Last), _Comp) {}
template <input_iterator _Iter, _Allocator_for<container_type> _Alloc>
template <input_iterator _Iter, _Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(_Iter _First, _Iter _Last, const key_compare& _Comp, const _Alloc& _Al)
: _Mycont(_STD make_obj_using_allocator<container_type>(_Al)), _Mycomp(_Comp) {
_Mycont.assign(_First, _Last);
_Make_invariants_fulfilled();
}
template <input_iterator _Iter, _Allocator_for<container_type> _Alloc>
template <input_iterator _Iter, _Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(_Iter _First, _Iter _Last, const _Alloc& _Al)
: _Mycont(_STD make_obj_using_allocator<container_type>(_Al)), _Mycomp() {
_Mycont.assign(_First, _Last);
@ -125,7 +113,7 @@ public:
template <_Container_compatible_range<_Kty> _Rng>
_Base_flat_set(from_range_t, _Rng&& _Range)
: _Base_flat_set(container_type(from_range, _STD forward<_Rng>(_Range))) {}
template <_Container_compatible_range<_Kty> _Rng, _Allocator_for<container_type> _Alloc>
template <_Container_compatible_range<_Kty> _Rng, _Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(from_range_t, _Rng&& _Range, const _Alloc& _Al)
: _Mycont(_STD make_obj_using_allocator<container_type>(_Al)), _Mycomp() {
_Mycont.assign_range(_STD forward<_Rng>(_Range));
@ -134,7 +122,7 @@ public:
template <_Container_compatible_range<_Kty> _Rng>
_Base_flat_set(from_range_t, _Rng&& _Range, const key_compare& _Comp)
: _Base_flat_set(container_type(from_range, _STD forward<_Rng>(_Range)), _Comp) {}
template <_Container_compatible_range<_Kty> _Rng, _Allocator_for<container_type> _Alloc>
template <_Container_compatible_range<_Kty> _Rng, _Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(from_range_t, _Rng&& _Range, const key_compare& _Comp, const _Alloc& _Al)
: _Mycont(_STD make_obj_using_allocator<container_type>(_Al)), _Mycomp(_Comp) {
_Mycont.assign_range(_STD forward<_Rng>(_Range));
@ -144,28 +132,28 @@ public:
template <input_iterator _Iter>
_Base_flat_set(_Tsorted _Tsort, _Iter _First, _Iter _Last, const key_compare& _Comp = key_compare())
: _Base_flat_set(_Tsort, container_type(_First, _Last), _Comp) {}
template <input_iterator _Iter, _Allocator_for<container_type> _Alloc>
template <input_iterator _Iter, _Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(_Tsorted _Tsort, _Iter _First, _Iter _Last, const key_compare& _Comp, const _Alloc& _Al)
: _Base_flat_set(_Tsort, _STD make_obj_using_allocator<container_type>(_Al, _First, _Last), _Comp) {}
template <input_iterator _Iter, _Allocator_for<container_type> _Alloc>
template <input_iterator _Iter, _Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(_Tsorted _Tsort, _Iter _First, _Iter _Last, const _Alloc& _Al)
: _Base_flat_set(_Tsort, _STD make_obj_using_allocator<container_type>(_Al, _First, _Last)) {}
_Base_flat_set(initializer_list<_Kty> _Ilist, const key_compare& _Comp = key_compare())
: _Base_flat_set(container_type(_Ilist), _Comp) {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(initializer_list<_Kty> _Ilist, const key_compare& _Comp, const _Alloc& _Al)
: _Base_flat_set(_Ilist.begin(), _Ilist.end(), _Comp, _Al) {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(initializer_list<_Kty> _Ilist, const _Alloc& _Al)
: _Base_flat_set(_Ilist.begin(), _Ilist.end(), _Al) {}
_Base_flat_set(_Tsorted _Tsort, initializer_list<_Kty> _Ilist, const key_compare& _Comp = key_compare())
: _Base_flat_set(_Tsort, container_type(_Ilist), _Comp) {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(_Tsorted _Tsort, initializer_list<_Kty> _Ilist, const key_compare& _Comp, const _Alloc& _Al)
: _Base_flat_set(_Tsort, _Ilist.begin(), _Ilist.end(), _Comp, _Al) {}
template <_Allocator_for<container_type> _Alloc>
template <_Usable_allocator_for<container_type> _Alloc>
_Base_flat_set(_Tsorted _Tsort, initializer_list<_Kty> _Ilist, const _Alloc& _Al)
: _Base_flat_set(_Tsort, _Ilist.begin(), _Ilist.end(), _Al) {}

Просмотреть файл

@ -3950,6 +3950,8 @@ _CONSTEXPR20 _OutIt _Copy_vbool(_VbIt _First, _VbIt _Last, _OutIt _Dest) {
#undef _INSERT_VECTOR_ANNOTATION
#if _HAS_CXX23
// This `flat_meow` machinery is here because `vector` is the leaf-most header included by both `flat_meow` headers.
_EXPORT_STD struct sorted_unique_t {
explicit sorted_unique_t() = default;
};
@ -3959,6 +3961,28 @@ _EXPORT_STD struct sorted_equivalent_t {
explicit sorted_equivalent_t() = default;
};
_EXPORT_STD inline constexpr sorted_equivalent_t sorted_equivalent{};
template <class>
constexpr bool _Is_vector_bool = false;
template <class _Alloc>
constexpr bool _Is_vector_bool<vector<bool, _Alloc>> = true;
template <class _Alloc, class... _Containers>
concept _Usable_allocator_for = (uses_allocator_v<_Containers, _Alloc> && ...);
template <class _Ty>
struct _NODISCARD _Clear_guard {
_Ty* _Target;
_Clear_guard& operator=(const _Clear_guard&) = delete;
_Clear_guard& operator=(_Clear_guard&&) = delete;
~_Clear_guard() {
if (_Target) {
_Target->clear();
}
}
};
#endif // ^^^ _HAS_CXX23 ^^^
_STD_END