Delete `std::experimental::erase/erase_if` (#4470)

This commit is contained in:
Stephan T. Lavavej 2024-03-15 22:49:06 -07:00 коммит произвёл GitHub
Родитель 4ce6bb37dd
Коммит a2869936fc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
16 изменённых файлов: 21 добавлений и 569 удалений

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

@ -68,18 +68,9 @@ set(HEADERS
${CMAKE_CURRENT_LIST_DIR}/inc/execution
${CMAKE_CURRENT_LIST_DIR}/inc/expected
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/coroutine
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/deque
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/filesystem
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/forward_list
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/generator
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/list
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/map
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/resumable
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/set
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/string
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/unordered_map
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/unordered_set
${CMAKE_CURRENT_LIST_DIR}/inc/experimental/vector
${CMAKE_CURRENT_LIST_DIR}/inc/filesystem
${CMAKE_CURRENT_LIST_DIR}/inc/format
${CMAKE_CURRENT_LIST_DIR}/inc/forward_list

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

@ -155,16 +155,7 @@
#include <ctgmath>
// Non-Core Experimental Headers
#include <experimental/deque>
#include <experimental/filesystem>
#include <experimental/forward_list>
#include <experimental/list>
#include <experimental/map>
#include <experimental/set>
#include <experimental/string>
#include <experimental/unordered_map>
#include <experimental/unordered_set>
#include <experimental/vector>
#endif // !defined(_CORE_HEADERS_ONLY)

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

@ -1,44 +0,0 @@
// deque experimental header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _EXPERIMENTAL_DEQUE_
#define _EXPERIMENTAL_DEQUE_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <deque>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
namespace experimental {
inline namespace fundamentals_v2 {
template <class _Ty, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(deque<_Ty, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_remove_if(_Cont, _STD _Pass_fn(_Pred));
}
template <class _Ty, class _Alloc, class _Uty>
_DEPRECATE_EXPERIMENTAL_ERASE void erase(deque<_Ty, _Alloc>& _Cont, const _Uty& _Val) {
_STD _Erase_remove(_Cont, _Val);
}
} // namespace fundamentals_v2
} // namespace experimental
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPERIMENTAL_DEQUE_

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

@ -1,44 +0,0 @@
// forward_list experimental header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _EXPERIMENTAL_FORWARD_LIST_
#define _EXPERIMENTAL_FORWARD_LIST_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <forward_list>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
namespace experimental {
inline namespace fundamentals_v2 {
template <class _Ty, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(forward_list<_Ty, _Alloc>& _Cont, _Pr _Pred) {
_Cont.remove_if(_STD _Pass_fn(_Pred));
}
template <class _Ty, class _Alloc, class _Uty>
_DEPRECATE_EXPERIMENTAL_ERASE void erase(forward_list<_Ty, _Alloc>& _Cont, const _Uty& _Val) {
_Cont.remove_if([&](_Ty& _Elem) { return _Elem == _Val; });
}
} // namespace fundamentals_v2
} // namespace experimental
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPERIMENTAL_FORWARD_LIST_

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

@ -1,44 +0,0 @@
// list experimental header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _EXPERIMENTAL_LIST_
#define _EXPERIMENTAL_LIST_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <list>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
namespace experimental {
inline namespace fundamentals_v2 {
template <class _Ty, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(list<_Ty, _Alloc>& _Cont, _Pr _Pred) {
_Cont.remove_if(_STD _Pass_fn(_Pred));
}
template <class _Ty, class _Alloc, class _Uty>
_DEPRECATE_EXPERIMENTAL_ERASE void erase(list<_Ty, _Alloc>& _Cont, const _Uty& _Val) {
_Cont.remove_if([&](_Ty& _Elem) { return _Elem == _Val; });
}
} // namespace fundamentals_v2
} // namespace experimental
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPERIMENTAL_LIST_

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

@ -1,44 +0,0 @@
// map experimental header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _EXPERIMENTAL_MAP_
#define _EXPERIMENTAL_MAP_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <map>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
namespace experimental {
inline namespace fundamentals_v2 {
template <class _Kty, class _Ty, class _Keylt, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(map<_Kty, _Ty, _Keylt, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_nodes_if(_Cont, _STD _Pass_fn(_Pred));
}
template <class _Kty, class _Ty, class _Keylt, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(multimap<_Kty, _Ty, _Keylt, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_nodes_if(_Cont, _STD _Pass_fn(_Pred));
}
} // namespace fundamentals_v2
} // namespace experimental
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPERIMENTAL_MAP_

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

@ -1,44 +0,0 @@
// set experimental header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _EXPERIMENTAL_SET_
#define _EXPERIMENTAL_SET_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <set>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
namespace experimental {
inline namespace fundamentals_v2 {
template <class _Kty, class _Keylt, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(set<_Kty, _Keylt, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_nodes_if(_Cont, _STD _Pass_fn(_Pred));
}
template <class _Kty, class _Keylt, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(multiset<_Kty, _Keylt, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_nodes_if(_Cont, _STD _Pass_fn(_Pred));
}
} // namespace fundamentals_v2
} // namespace experimental
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPERIMENTAL_SET_

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

@ -1,44 +0,0 @@
// string experimental header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _EXPERIMENTAL_STRING_
#define _EXPERIMENTAL_STRING_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <xstring>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
namespace experimental {
inline namespace fundamentals_v2 {
template <class _Elem, class _Traits, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(basic_string<_Elem, _Traits, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_remove_if(_Cont, _STD _Pass_fn(_Pred));
}
template <class _Elem, class _Traits, class _Alloc, class _Uty>
_DEPRECATE_EXPERIMENTAL_ERASE void erase(basic_string<_Elem, _Traits, _Alloc>& _Cont, const _Uty& _Val) {
_STD _Erase_remove(_Cont, _Val);
}
} // namespace fundamentals_v2
} // namespace experimental
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPERIMENTAL_STRING_

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

@ -1,46 +0,0 @@
// unordered_map experimental header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _EXPERIMENTAL_UNORDERED_MAP_
#define _EXPERIMENTAL_UNORDERED_MAP_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <unordered_map>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
namespace experimental {
inline namespace fundamentals_v2 {
template <class _Kty, class _Ty, class _Hasher, class _Keyeq, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(
unordered_map<_Kty, _Ty, _Hasher, _Keyeq, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_nodes_if(_Cont, _STD _Pass_fn(_Pred));
}
template <class _Kty, class _Ty, class _Hasher, class _Keyeq, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(
unordered_multimap<_Kty, _Ty, _Hasher, _Keyeq, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_nodes_if(_Cont, _STD _Pass_fn(_Pred));
}
} // namespace fundamentals_v2
} // namespace experimental
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPERIMENTAL_UNORDERED_MAP_

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

@ -1,45 +0,0 @@
// unordered_set experimental header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _EXPERIMENTAL_UNORDERED_SET_
#define _EXPERIMENTAL_UNORDERED_SET_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <unordered_set>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
namespace experimental {
inline namespace fundamentals_v2 {
template <class _Kty, class _Hasher, class _Keyeq, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(unordered_set<_Kty, _Hasher, _Keyeq, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_nodes_if(_Cont, _STD _Pass_fn(_Pred));
}
template <class _Kty, class _Hasher, class _Keyeq, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(
unordered_multiset<_Kty, _Hasher, _Keyeq, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_nodes_if(_Cont, _STD _Pass_fn(_Pred));
}
} // namespace fundamentals_v2
} // namespace experimental
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPERIMENTAL_UNORDERED_SET_

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

@ -1,44 +0,0 @@
// vector experimental header
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef _EXPERIMENTAL_VECTOR_
#define _EXPERIMENTAL_VECTOR_
#include <yvals_core.h>
#if _STL_COMPILER_PREPROCESSOR
#include <vector>
#pragma pack(push, _CRT_PACKING)
#pragma warning(push, _STL_WARNING_LEVEL)
#pragma warning(disable : _STL_DISABLED_WARNINGS)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
_STD_BEGIN
namespace experimental {
inline namespace fundamentals_v2 {
template <class _Ty, class _Alloc, class _Pr>
_DEPRECATE_EXPERIMENTAL_ERASE void erase_if(vector<_Ty, _Alloc>& _Cont, _Pr _Pred) {
_STD _Erase_remove_if(_Cont, _STD _Pass_fn(_Pred));
}
template <class _Ty, class _Alloc, class _Uty>
_DEPRECATE_EXPERIMENTAL_ERASE void erase(vector<_Ty, _Alloc>& _Cont, const _Uty& _Val) {
_STD _Erase_remove(_Cont, _Val);
}
} // namespace fundamentals_v2
} // namespace experimental
_STD_END
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma pack(pop)
#endif // _STL_COMPILER_PREPROCESSOR
#endif // _EXPERIMENTAL_VECTOR_

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

@ -1324,15 +1324,8 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect
#define _CXX20_DEPRECATE_IS_POD
#endif // ^^^ warning disabled ^^^
#if _HAS_CXX20 && !defined(_SILENCE_EXPERIMENTAL_ERASE_DEPRECATION_WARNING)
#define _DEPRECATE_EXPERIMENTAL_ERASE \
[[deprecated("warning STL4026: " \
"std::experimental::erase() and std::experimental::erase_if() are deprecated by Microsoft and will " \
"be REMOVED. They are superseded by std::erase() and std::erase_if(). " \
"You can define _SILENCE_EXPERIMENTAL_ERASE_DEPRECATION_WARNING to suppress this warning.")]]
#else // ^^^ warning enabled / warning disabled vvv
#define _DEPRECATE_EXPERIMENTAL_ERASE
#endif // ^^^ warning disabled ^^^
// STL4026 was
// "std::experimental::erase() and std::experimental::erase_if() are deprecated by Microsoft and will be REMOVED."
// P0768R1 [depr.relops]
#if _HAS_CXX20 && !defined(_SILENCE_CXX20_REL_OPS_DEPRECATION_WARNING) \
@ -1897,7 +1890,6 @@ _EMIT_STL_ERROR(STL1004, "C++98 unexpected() is incompatible with C++23 unexpect
#define __cpp_lib_variant 202102L // P2162R2 Inheriting From variant
#endif
#define __cpp_lib_experimental_erase_if 201411L
#define __cpp_lib_experimental_filesystem 201406L
#ifdef _RTC_CONVERSION_CHECKS_ENABLED

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

@ -4,7 +4,6 @@
#define _HAS_DEPRECATED_RAW_STORAGE_ITERATOR 1
#define _SILENCE_CXX17_RAW_STORAGE_ITERATOR_DEPRECATION_WARNING
#define _SILENCE_CXX23_ALIGNED_UNION_DEPRECATION_WARNING
#define _SILENCE_EXPERIMENTAL_ERASE_DEPRECATION_WARNING
#include <algorithm>
#include <array>
@ -13,15 +12,6 @@
#include <complex>
#include <cstddef>
#include <deque>
#include <experimental/deque>
#include <experimental/forward_list>
#include <experimental/list>
#include <experimental/map>
#include <experimental/set>
#include <experimental/string>
#include <experimental/unordered_map>
#include <experimental/unordered_set>
#include <experimental/vector>
#include <forward_list>
#include <iterator>
#include <list>
@ -379,106 +369,18 @@ int main() {
}
// N4273 Uniform Container Erasure
{
// Note that the standard actually requires these to be copyable. As an extension, we want
// to ensure we don't copy them, because copying some functors (e.g. std::function) is comparatively
// expensive, and even for relatively cheap to copy function objects we care (somewhat) about debug
// mode perf.
struct no_copy {
no_copy() = default;
no_copy(const no_copy&) = delete;
no_copy(no_copy&&) = default;
no_copy& operator=(const no_copy&) = delete;
no_copy& operator=(no_copy&&) = delete;
};
struct is_vowel : no_copy {
bool operator()(const char c) const {
return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}
};
std::string str1{"cute fluffy kittens"};
std::experimental::erase_if(str1, is_vowel{});
assert(str1 == "ct flffy kttns");
std::string str2{"asynchronous beat"};
std::experimental::erase(str2, 'a');
assert(str2 == "synchronous bet");
struct is_odd : no_copy {
bool operator()(const int i) const {
return i % 2 != 0;
}
};
std::deque<int> d{1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1};
std::experimental::erase_if(d, is_odd{});
assert((d == std::deque<int>{2, 4, 6, 6, 4, 2}));
std::experimental::erase(d, 4);
assert((d == std::deque<int>{2, 6, 6, 2}));
std::vector<int> v{1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1};
std::experimental::erase_if(v, is_odd{});
assert((v == std::vector<int>{2, 4, 6, 6, 4, 2}));
std::experimental::erase(v, 4);
assert((v == std::vector<int>{2, 6, 6, 2}));
std::forward_list<int> fl{1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1};
std::experimental::erase_if(fl, is_odd{});
assert((fl == std::forward_list<int>{2, 4, 6, 6, 4, 2}));
std::experimental::erase(fl, 4);
assert((fl == std::forward_list<int>{2, 6, 6, 2}));
std::list<int> l{1, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 2, 1};
std::experimental::erase_if(l, is_odd{});
assert((l == std::list<int>{2, 4, 6, 6, 4, 2}));
std::experimental::erase(l, 4);
assert((l == std::list<int>{2, 6, 6, 2}));
struct is_first_odd : no_copy {
bool operator()(const std::pair<const int, int>& p) const {
return p.first % 2 != 0;
}
};
std::map<int, int> m{{1, 10}, {2, 20}, {3, 30}, {4, 40}, {5, 50}, {6, 60}, {7, 70}};
std::experimental::erase_if(m, is_first_odd{});
assert((m == std::map<int, int>{{2, 20}, {4, 40}, {6, 60}}));
std::multimap<int, int> mm{{1, 10}, {2, 20}, {3, 30}, {4, 40}, {5, 50}, {6, 60}, {7, 70}};
std::experimental::erase_if(mm, is_first_odd{});
assert((mm == std::multimap<int, int>{{2, 20}, {4, 40}, {6, 60}}));
std::set<int> s{1, 2, 3, 4, 5, 6, 7};
std::experimental::erase_if(s, is_odd{});
assert((s == std::set<int>{2, 4, 6}));
std::multiset<int> ms{1, 2, 3, 4, 5, 6, 7};
std::experimental::erase_if(ms, is_odd{});
assert((ms == std::multiset<int>{2, 4, 6}));
// Note that unordered equality considers permutations.
std::unordered_map<int, int> um{{1, 10}, {2, 20}, {3, 30}, {4, 40}, {5, 50}, {6, 60}, {7, 70}};
std::experimental::erase_if(um, is_first_odd{});
assert((um == std::unordered_map<int, int>{{2, 20}, {4, 40}, {6, 60}}));
std::unordered_multimap<int, int> umm{{1, 10}, {2, 20}, {3, 30}, {4, 40}, {5, 50}, {6, 60}, {7, 70}};
std::experimental::erase_if(umm, is_first_odd{});
assert((umm == std::unordered_multimap<int, int>{{2, 20}, {4, 40}, {6, 60}}));
std::unordered_set<int> us{1, 2, 3, 4, 5, 6, 7};
std::experimental::erase_if(us, is_odd{});
assert((us == std::unordered_set<int>{2, 4, 6}));
std::unordered_multiset<int> ums{1, 2, 3, 4, 5, 6, 7};
std::experimental::erase_if(ums, is_odd{});
assert((ums == std::unordered_multiset<int>{2, 4, 6}));
// P0458R2 contains() For Ordered And Unordered Associative Containers
#if _HAS_CXX20
// P0458R2 contains() For Ordered And Unordered Associative Containers
{
std::map<int, int> m = {{2, 20}, {4, 40}, {6, 60}};
std::multimap<int, int> mm = {{2, 20}, {4, 40}, {6, 60}};
std::set<int> s = {2, 4, 6};
std::multiset<int> ms = {2, 4, 6};
std::unordered_map<int, int> um = {{2, 20}, {4, 40}, {6, 60}};
std::unordered_multimap<int, int> umm = {{2, 20}, {4, 40}, {6, 60}};
std::unordered_set<int> us = {2, 4, 6};
std::unordered_multiset<int> ums = {2, 4, 6};
assert(m.contains(2));
assert(mm.contains(4));
assert(s.contains(6));
@ -532,10 +434,8 @@ int main() {
assert(!const_umm.contains(5));
assert(!const_us.contains(1));
assert(!const_ums.contains(3));
#endif // _HAS_CXX20
}
#if _HAS_CXX20
// P1209R0 erase_if(), erase()
{
// Note that the standard actually requires these to be copyable. As an extension, we want

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

@ -2,22 +2,12 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#define _USE_NAMED_IDL_NAMESPACE 1
#define _SILENCE_EXPERIMENTAL_ERASE_DEPRECATION_WARNING
#define _SILENCE_STDEXT_HASH_DEPRECATION_WARNINGS
#include <array>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <experimental/deque>
#include <experimental/forward_list>
#include <experimental/list>
#include <experimental/map>
#include <experimental/set>
#include <experimental/string>
#include <experimental/unordered_map>
#include <experimental/unordered_set>
#include <experimental/vector>
#include <forward_list>
#include <hash_map>
#include <hash_set>
@ -285,25 +275,24 @@ void insert_with_iterator_test(T value) {
template <typename T>
void erase_if_test(T value) {
auto pr1 = [](auto) { return false; };
std::experimental::fundamentals_v2::erase_if(value, pr1);
#ifndef _M_CEE // TRANSITION, VSO-1659496
std::experimental::fundamentals_v2::erase_if(value, validating_falsity{});
#endif // ^^^ no workaround ^^^
#if _HAS_CXX20
auto pr1 = [](auto) { return false; };
std::erase_if(value, pr1);
#ifndef _M_CEE // TRANSITION, VSO-1659496
std::erase_if(value, validating_falsity{});
#endif // ^^^ no workaround ^^^
#endif // _HAS_CXX20
#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
(void) value;
#endif // ^^^ !_HAS_CXX20 ^^^
}
template <typename T>
void erase_test(T value) {
std::experimental::fundamentals_v2::erase(value, static_cast<typename T::value_type>(1));
#if _HAS_CXX20
std::erase(value, static_cast<typename T::value_type>(1));
#endif // _HAS_CXX20
#else // ^^^ _HAS_CXX20 / !_HAS_CXX20 vvv
(void) value;
#endif // ^^^ !_HAS_CXX20 ^^^
}
template <typename T>
@ -640,9 +629,8 @@ void vector_test() {
vector_test_impl<vector<bool>>();
erase_test(vector<int>());
vector<bool> vb;
std::experimental::fundamentals_v2::erase(vb, true);
#if _HAS_CXX20
vector<bool> vb;
std::erase(vb, true);
#endif // _HAS_CXX20

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

@ -345,8 +345,6 @@ STATIC_ASSERT(__cpp_lib_expected == 202211L);
#error __cpp_lib_expected is defined
#endif
STATIC_ASSERT(__cpp_lib_experimental_erase_if == 201411L);
STATIC_ASSERT(__cpp_lib_experimental_filesystem == 201406L);
#if _HAS_CXX17

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

@ -91,15 +91,6 @@ PM_CL="/DMEOW_HEADER=valarray"
PM_CL="/DMEOW_HEADER=variant"
PM_CL="/DMEOW_HEADER=vector"
PM_CL="/DMEOW_HEADER=version"
PM_CL="/DMEOW_HEADER=experimental/deque"
PM_CL="/DMEOW_HEADER=experimental/forward_list"
PM_CL="/DMEOW_HEADER=experimental/list"
PM_CL="/DMEOW_HEADER=experimental/map"
PM_CL="/DMEOW_HEADER=experimental/set"
PM_CL="/DMEOW_HEADER=experimental/string"
PM_CL="/DMEOW_HEADER=experimental/unordered_map"
PM_CL="/DMEOW_HEADER=experimental/unordered_set"
PM_CL="/DMEOW_HEADER=experimental/vector"
PM_CL="/DMEOW_HEADER=cassert"
PM_CL="/DMEOW_HEADER=ccomplex /D_SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING"
PM_CL="/DMEOW_HEADER=cctype"