Commit 45a8d80f by Jonathan Wakely Committed by Jonathan Wakely

Define __cpp_lib_erase_if feature test macro

The C++2a draft specifies the value 201811L for this, but as an
extension we return the number of elements erased. This is expected to
be standardised, so the macro has the value 201900L until a proper value
is specified in the draft.

	* include/bits/erase_if.h: Define __cpp_lib_erase_if.
	* include/std/deque: Likewise.
	* include/std/forward_list: Likewise.
	* include/std/list: Likewise.
	* include/std/string: Likewise.
	* include/std/vector: Likewise.
	* include/std/version: Likewise.
	* testsuite/21_strings/basic_string/erasure.cc: Test macro.
	* testsuite/23_containers/deque/erasure.cc: Likewise.
	* testsuite/23_containers/forward_list/erasure.cc: Likewise.
	* testsuite/23_containers/list/erasure.cc: Likewise.
	* testsuite/23_containers/map/erasure.cc: Likewise.
	* testsuite/23_containers/set/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
	* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
	* testsuite/23_containers/vector/erasure.cc: Likewise.

From-SVN: r267810
parent cbe0bca4
2019-01-10 Jonathan Wakely <jwakely@redhat.com> 2019-01-10 Jonathan Wakely <jwakely@redhat.com>
* include/bits/erase_if.h: Define __cpp_lib_erase_if.
* include/std/deque: Likewise.
* include/std/forward_list: Likewise.
* include/std/list: Likewise.
* include/std/string: Likewise.
* include/std/vector: Likewise.
* include/std/version: Likewise.
* testsuite/21_strings/basic_string/erasure.cc: Test macro.
* testsuite/23_containers/deque/erasure.cc: Likewise.
* testsuite/23_containers/forward_list/erasure.cc: Likewise.
* testsuite/23_containers/list/erasure.cc: Likewise.
* testsuite/23_containers/map/erasure.cc: Likewise.
* testsuite/23_containers/set/erasure.cc: Likewise.
* testsuite/23_containers/unordered_map/erasure.cc: Likewise.
* testsuite/23_containers/unordered_set/erasure.cc: Likewise.
* testsuite/23_containers/vector/erasure.cc: Likewise.
* include/experimental/internet [AI_NUMERICSERV] * include/experimental/internet [AI_NUMERICSERV]
(resolver_base::numeric_service): Define conditionally. (resolver_base::numeric_service): Define conditionally.
* testsuite/experimental/net/internet/resolver/base.cc: Test it * testsuite/experimental/net/internet/resolver/base.cc: Test it
......
...@@ -38,6 +38,8 @@ namespace std ...@@ -38,6 +38,8 @@ namespace std
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_erase_if 201900L
namespace __detail namespace __detail
{ {
template<typename _Container, typename _Predicate> template<typename _Container, typename _Predicate>
......
...@@ -94,6 +94,9 @@ _GLIBCXX_END_NAMESPACE_VERSION ...@@ -94,6 +94,9 @@ _GLIBCXX_END_NAMESPACE_VERSION
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_erase_if 201900L
template<typename _Tp, typename _Alloc, typename _Predicate> template<typename _Tp, typename _Alloc, typename _Predicate>
inline typename deque<_Tp, _Alloc>::size_type inline typename deque<_Tp, _Alloc>::size_type
erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred) erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred)
......
...@@ -65,6 +65,9 @@ _GLIBCXX_END_NAMESPACE_VERSION ...@@ -65,6 +65,9 @@ _GLIBCXX_END_NAMESPACE_VERSION
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_erase_if 201900L
template<typename _Tp, typename _Alloc, typename _Predicate> template<typename _Tp, typename _Alloc, typename _Predicate>
inline typename forward_list<_Tp, _Alloc>::size_type inline typename forward_list<_Tp, _Alloc>::size_type
erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred) erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred)
......
...@@ -89,6 +89,9 @@ _GLIBCXX_END_NAMESPACE_VERSION ...@@ -89,6 +89,9 @@ _GLIBCXX_END_NAMESPACE_VERSION
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_erase_if 201900L
template<typename _Tp, typename _Alloc, typename _Predicate> template<typename _Tp, typename _Alloc, typename _Predicate>
inline typename list<_Tp, _Alloc>::size_type inline typename list<_Tp, _Alloc>::size_type
erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred) erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred)
......
...@@ -79,6 +79,9 @@ _GLIBCXX_END_NAMESPACE_VERSION ...@@ -79,6 +79,9 @@ _GLIBCXX_END_NAMESPACE_VERSION
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_erase_if 201900L
template<typename _CharT, typename _Traits, typename _Alloc, template<typename _CharT, typename _Traits, typename _Alloc,
typename _Predicate> typename _Predicate>
inline typename basic_string<_CharT, _Traits, _Alloc>::size_type inline typename basic_string<_CharT, _Traits, _Alloc>::size_type
......
...@@ -97,6 +97,9 @@ _GLIBCXX_END_NAMESPACE_VERSION ...@@ -97,6 +97,9 @@ _GLIBCXX_END_NAMESPACE_VERSION
namespace std _GLIBCXX_VISIBILITY(default) namespace std _GLIBCXX_VISIBILITY(default)
{ {
_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_BEGIN_NAMESPACE_VERSION
#define __cpp_lib_erase_if 201900L
template<typename _Tp, typename _Alloc, typename _Predicate> template<typename _Tp, typename _Alloc, typename _Predicate>
inline typename vector<_Tp, _Alloc>::size_type inline typename vector<_Tp, _Alloc>::size_type
erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred) erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred)
......
...@@ -96,6 +96,7 @@ ...@@ -96,6 +96,7 @@
#define __cpp_lib_clamp 201603 #define __cpp_lib_clamp 201603
#define __cpp_lib_constexpr_char_traits 201611 #define __cpp_lib_constexpr_char_traits 201611
#define __cpp_lib_enable_shared_from_this 201603 #define __cpp_lib_enable_shared_from_this 201603
#define __cpp_lib_erase_if 201900L
#define __cpp_lib_filesystem 201703 #define __cpp_lib_filesystem 201703
#define __cpp_lib_gcd 201606 #define __cpp_lib_gcd 201606
#define __cpp_lib_gcd_lcm 201606 #define __cpp_lib_gcd_lcm 201606
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
#include <deque> #include <deque>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#ifndef __cpp_lib_erase_if
# error "Feature-test macro for erase_if missing"
#elif __cpp_lib_erase_if < 201811
# error "Feature-test macro for erase_if has wrong value"
#endif
void void
test01() test01()
{ {
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
#include <forward_list> #include <forward_list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#ifndef __cpp_lib_erase_if
# error "Feature-test macro for erase_if missing"
#elif __cpp_lib_erase_if < 201811
# error "Feature-test macro for erase_if has wrong value"
#endif
void void
test01() test01()
{ {
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
#include <list> #include <list>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#ifndef __cpp_lib_erase_if
# error "Feature-test macro for erase_if missing"
#elif __cpp_lib_erase_if < 201811
# error "Feature-test macro for erase_if has wrong value"
#endif
void void
test01() test01()
{ {
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
#include <map> #include <map>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#ifndef __cpp_lib_erase_if
# error "Feature-test macro for erase_if missing"
#elif __cpp_lib_erase_if < 201811
# error "Feature-test macro for erase_if has wrong value"
#endif
auto is_odd_pair = [](const std::pair<const int, std::string>& p) auto is_odd_pair = [](const std::pair<const int, std::string>& p)
{ {
return p.first % 2 != 0; return p.first % 2 != 0;
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
#include <set> #include <set>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#ifndef __cpp_lib_erase_if
# error "Feature-test macro for erase_if missing"
#elif __cpp_lib_erase_if < 201811
# error "Feature-test macro for erase_if has wrong value"
#endif
auto is_odd = [](const int i) { return i % 2 != 0; }; auto is_odd = [](const int i) { return i % 2 != 0; };
void void
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
#include <unordered_map> #include <unordered_map>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#ifndef __cpp_lib_erase_if
# error "Feature-test macro for erase_if missing"
#elif __cpp_lib_erase_if < 201811
# error "Feature-test macro for erase_if has wrong value"
#endif
auto is_odd_pair = [](const std::pair<const int, std::string>& p) auto is_odd_pair = [](const std::pair<const int, std::string>& p)
{ {
return p.first % 2 != 0; return p.first % 2 != 0;
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
#include <unordered_set> #include <unordered_set>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#ifndef __cpp_lib_erase_if
# error "Feature-test macro for erase_if missing"
#elif __cpp_lib_erase_if < 201811
# error "Feature-test macro for erase_if has wrong value"
#endif
void void
test01() test01()
{ {
......
...@@ -21,6 +21,12 @@ ...@@ -21,6 +21,12 @@
#include <vector> #include <vector>
#include <testsuite_hooks.h> #include <testsuite_hooks.h>
#ifndef __cpp_lib_erase_if
# error "Feature-test macro for erase_if missing"
#elif __cpp_lib_erase_if < 201811
# error "Feature-test macro for erase_if has wrong value"
#endif
void void
test01() test01()
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment