From: Jonathan Wakely Date: Thu, 10 Jan 2019 13:49:31 +0000 (+0000) Subject: Define __cpp_lib_erase_if feature test macro X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=45a8d80fec060195ef6936e43b4fe70158fb7dc7;p=gcc.git 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 --- diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 19a12f8e163..00ebdddea72 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,5 +1,22 @@ 2019-01-10 Jonathan Wakely + * 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] (resolver_base::numeric_service): Define conditionally. * testsuite/experimental/net/internet/resolver/base.cc: Test it diff --git a/libstdc++-v3/include/bits/erase_if.h b/libstdc++-v3/include/bits/erase_if.h index 9e865c6abb5..d84f5ffc8ed 100644 --- a/libstdc++-v3/include/bits/erase_if.h +++ b/libstdc++-v3/include/bits/erase_if.h @@ -38,6 +38,8 @@ namespace std { _GLIBCXX_BEGIN_NAMESPACE_VERSION +#define __cpp_lib_erase_if 201900L + namespace __detail { template diff --git a/libstdc++-v3/include/std/deque b/libstdc++-v3/include/std/deque index 7932b1cdea5..ed4927e13b7 100644 --- a/libstdc++-v3/include/std/deque +++ b/libstdc++-v3/include/std/deque @@ -94,6 +94,9 @@ _GLIBCXX_END_NAMESPACE_VERSION namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 201900L + template inline typename deque<_Tp, _Alloc>::size_type erase_if(deque<_Tp, _Alloc>& __cont, _Predicate __pred) diff --git a/libstdc++-v3/include/std/forward_list b/libstdc++-v3/include/std/forward_list index 93c95904fc3..3d3b6d4f5f6 100644 --- a/libstdc++-v3/include/std/forward_list +++ b/libstdc++-v3/include/std/forward_list @@ -65,6 +65,9 @@ _GLIBCXX_END_NAMESPACE_VERSION namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 201900L + template inline typename forward_list<_Tp, _Alloc>::size_type erase_if(forward_list<_Tp, _Alloc>& __cont, _Predicate __pred) diff --git a/libstdc++-v3/include/std/list b/libstdc++-v3/include/std/list index 5ea9a9619ba..7b02e8685d4 100644 --- a/libstdc++-v3/include/std/list +++ b/libstdc++-v3/include/std/list @@ -89,6 +89,9 @@ _GLIBCXX_END_NAMESPACE_VERSION namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 201900L + template inline typename list<_Tp, _Alloc>::size_type erase_if(list<_Tp, _Alloc>& __cont, _Predicate __pred) diff --git a/libstdc++-v3/include/std/string b/libstdc++-v3/include/std/string index dc718b87357..caa54c24100 100644 --- a/libstdc++-v3/include/std/string +++ b/libstdc++-v3/include/std/string @@ -79,6 +79,9 @@ _GLIBCXX_END_NAMESPACE_VERSION namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 201900L + template inline typename basic_string<_CharT, _Traits, _Alloc>::size_type diff --git a/libstdc++-v3/include/std/vector b/libstdc++-v3/include/std/vector index 059451801cb..2c90765b058 100644 --- a/libstdc++-v3/include/std/vector +++ b/libstdc++-v3/include/std/vector @@ -97,6 +97,9 @@ _GLIBCXX_END_NAMESPACE_VERSION namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION + +#define __cpp_lib_erase_if 201900L + template inline typename vector<_Tp, _Alloc>::size_type erase_if(vector<_Tp, _Alloc>& __cont, _Predicate __pred) diff --git a/libstdc++-v3/include/std/version b/libstdc++-v3/include/std/version index f090fba0308..e11ae3a688a 100644 --- a/libstdc++-v3/include/std/version +++ b/libstdc++-v3/include/std/version @@ -96,6 +96,7 @@ #define __cpp_lib_clamp 201603 #define __cpp_lib_constexpr_char_traits 201611 #define __cpp_lib_enable_shared_from_this 201603 +#define __cpp_lib_erase_if 201900L #define __cpp_lib_filesystem 201703 #define __cpp_lib_gcd 201606 #define __cpp_lib_gcd_lcm 201606 diff --git a/libstdc++-v3/testsuite/23_containers/deque/erasure.cc b/libstdc++-v3/testsuite/23_containers/deque/erasure.cc index 4fe6f1d0d6f..39ea6deecc2 100644 --- a/libstdc++-v3/testsuite/23_containers/deque/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/deque/erasure.cc @@ -21,6 +21,12 @@ #include #include +#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 test01() { diff --git a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc index 3d5c9fdcd57..724a720f654 100644 --- a/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/forward_list/erasure.cc @@ -21,6 +21,12 @@ #include #include +#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 test01() { diff --git a/libstdc++-v3/testsuite/23_containers/list/erasure.cc b/libstdc++-v3/testsuite/23_containers/list/erasure.cc index 87dfee990fc..a9927b484e1 100644 --- a/libstdc++-v3/testsuite/23_containers/list/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/list/erasure.cc @@ -21,6 +21,12 @@ #include #include +#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 test01() { diff --git a/libstdc++-v3/testsuite/23_containers/map/erasure.cc b/libstdc++-v3/testsuite/23_containers/map/erasure.cc index a19e805f7fc..d8a57160865 100644 --- a/libstdc++-v3/testsuite/23_containers/map/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/map/erasure.cc @@ -21,6 +21,12 @@ #include #include +#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& p) { return p.first % 2 != 0; diff --git a/libstdc++-v3/testsuite/23_containers/set/erasure.cc b/libstdc++-v3/testsuite/23_containers/set/erasure.cc index 0e178e9a177..2412d69f75c 100644 --- a/libstdc++-v3/testsuite/23_containers/set/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/set/erasure.cc @@ -21,6 +21,12 @@ #include #include +#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; }; void diff --git a/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc b/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc index f652dd2b5a7..35190a0d19e 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_map/erasure.cc @@ -21,6 +21,12 @@ #include #include +#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& p) { return p.first % 2 != 0; diff --git a/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc b/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc index 3f59bfdc205..5ffabf538bd 100644 --- a/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/unordered_set/erasure.cc @@ -21,6 +21,12 @@ #include #include +#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 test01() { diff --git a/libstdc++-v3/testsuite/23_containers/vector/erasure.cc b/libstdc++-v3/testsuite/23_containers/vector/erasure.cc index 9868252816c..0a23c3f0d12 100644 --- a/libstdc++-v3/testsuite/23_containers/vector/erasure.cc +++ b/libstdc++-v3/testsuite/23_containers/vector/erasure.cc @@ -21,6 +21,12 @@ #include #include +#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 test01() {