[libcxx-commits] [libcxx] 9d7ae0a - [libc++][NFC] Correct comment about P0600 missing node_handle bits
Louis Dionne via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Sep 1 07:52:06 PDT 2021
Author: Louis Dionne
Date: 2021-09-01T10:51:55-04:00
New Revision: 9d7ae0acde2c42b2dac101ec0a51387aa4a8fad9
URL: https://github.com/llvm/llvm-project/commit/9d7ae0acde2c42b2dac101ec0a51387aa4a8fad9
DIFF: https://github.com/llvm/llvm-project/commit/9d7ae0acde2c42b2dac101ec0a51387aa4a8fad9.diff
LOG: [libc++][NFC] Correct comment about P0600 missing node_handle bits
Differential Revision: https://reviews.llvm.org/D109027
Added:
libcxx/test/std/containers/container.node/node_handle.nodiscard.verify.cpp
Modified:
libcxx/docs/Status/Cxx20.rst
libcxx/test/std/containers/container.node/node_handle.pass.cpp
Removed:
################################################################################
diff --git a/libcxx/docs/Status/Cxx20.rst b/libcxx/docs/Status/Cxx20.rst
index 304f69f26f552..7d62339a45eb8 100644
--- a/libcxx/docs/Status/Cxx20.rst
+++ b/libcxx/docs/Status/Cxx20.rst
@@ -40,7 +40,7 @@ Paper Status
.. note::
- .. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class], |sect|\ [mem.poly.allocator.class], and |sect|\ [container.node.overview].
+ .. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class] and |sect|\ [mem.poly.allocator.class].
.. [#note-P0966] P0966: It was previously erroneously marked as complete in version 8.0. See `bug 45368 <https://llvm.org/PR45368>`__.
.. [#note-P0619] P0619: Only sections D.8, D.9, D.10 and D.13 are implemented. Sections D.4, D.7, D.11, D.12, and D.14 remain undone.
.. [#note-P0883] P0883: shared_ptr and floating-point changes weren't applied as they themselves aren't implemented yet.
diff --git a/libcxx/test/std/containers/container.node/node_handle.nodiscard.verify.cpp b/libcxx/test/std/containers/container.node/node_handle.nodiscard.verify.cpp
new file mode 100644
index 0000000000000..b94baace98945
--- /dev/null
+++ b/libcxx/test/std/containers/container.node/node_handle.nodiscard.verify.cpp
@@ -0,0 +1,52 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17
+
+// Make sure the various node handles mark their .empty() method with
+// [[nodiscard]] starting with C++20
+
+#include <map>
+#include <set>
+#include <unordered_map>
+#include <unordered_set>
+
+void test() {
+ {
+ std::map<int, int>::node_type node;
+ node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+ {
+ std::multimap<int, int>::node_type node;
+ node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+ {
+ std::set<int> node;
+ node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+ {
+ std::multiset<int> node;
+ node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+ {
+ std::unordered_map<int, int> node;
+ node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+ {
+ std::unordered_multimap<int, int> node;
+ node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+ {
+ std::unordered_set<int> node;
+ node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+ {
+ std::unordered_multiset<int> node;
+ node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
+ }
+}
diff --git a/libcxx/test/std/containers/container.node/node_handle.pass.cpp b/libcxx/test/std/containers/container.node/node_handle.pass.cpp
index 91d63cc42171d..1eab9042b9e13 100644
--- a/libcxx/test/std/containers/container.node/node_handle.pass.cpp
+++ b/libcxx/test/std/containers/container.node/node_handle.pass.cpp
@@ -15,29 +15,27 @@
#include "test_macros.h"
#include "min_allocator.h"
-using namespace std;
-
// [container.node.overview] Table 83.
template <class K, class T, class C1, class C2, class H1, class H2, class E1, class E2, class A_set, class A_map>
struct node_compatibility_table
{
static constexpr bool value =
- is_same_v<typename map<K, T, C1, A_map>::node_type, typename map<K, T, C2, A_map>::node_type> &&
- is_same_v<typename map<K, T, C1, A_map>::node_type, typename multimap<K, T, C2, A_map>::node_type> &&
- is_same_v<typename set<K, C1, A_set>::node_type, typename set<K, C2, A_set>::node_type> &&
- is_same_v<typename set<K, C1, A_set>::node_type, typename multiset<K, C2, A_set>::node_type> &&
- is_same_v<typename unordered_map<K, T, H1, E1, A_map>::node_type, typename unordered_map<K, T, H2, E2, A_map>::node_type> &&
- is_same_v<typename unordered_map<K, T, H1, E1, A_map>::node_type, typename unordered_multimap<K, T, H2, E2, A_map>::node_type> &&
- is_same_v<typename unordered_set<K, H1, E1, A_set>::node_type, typename unordered_set<K, H2, E2, A_set>::node_type> &&
- is_same_v<typename unordered_set<K, H1, E1, A_set>::node_type, typename unordered_multiset<K, H2, E2, A_set>::node_type>;
+ std::is_same_v<typename std::map<K, T, C1, A_map>::node_type, typename std::map<K, T, C2, A_map>::node_type> &&
+ std::is_same_v<typename std::map<K, T, C1, A_map>::node_type, typename std::multimap<K, T, C2, A_map>::node_type> &&
+ std::is_same_v<typename std::set<K, C1, A_set>::node_type, typename std::set<K, C2, A_set>::node_type> &&
+ std::is_same_v<typename std::set<K, C1, A_set>::node_type, typename std::multiset<K, C2, A_set>::node_type> &&
+ std::is_same_v<typename std::unordered_map<K, T, H1, E1, A_map>::node_type, typename std::unordered_map<K, T, H2, E2, A_map>::node_type> &&
+ std::is_same_v<typename std::unordered_map<K, T, H1, E1, A_map>::node_type, typename std::unordered_multimap<K, T, H2, E2, A_map>::node_type> &&
+ std::is_same_v<typename std::unordered_set<K, H1, E1, A_set>::node_type, typename std::unordered_set<K, H2, E2, A_set>::node_type> &&
+ std::is_same_v<typename std::unordered_set<K, H1, E1, A_set>::node_type, typename std::unordered_multiset<K, H2, E2, A_set>::node_type>;
};
template <class T> struct my_hash
{
using argument_type = T;
- using result_type = size_t;
+ using result_type = std::size_t;
my_hash() = default;
- size_t operator()(const T&) const {return 0;}
+ std::size_t operator()(const T&) const {return 0;}
};
template <class T> struct my_compare
@@ -66,9 +64,9 @@ namespace std
template <> struct hash<Static>
{
using argument_type = Static;
- using result_type = size_t;
+ using result_type = std::size_t;
hash() = default;
- size_t operator()(const Static&) const;
+ std::size_t operator()(const Static&) const;
};
}
@@ -82,8 +80,8 @@ static_assert(node_compatibility_table<
static_assert(
node_compatibility_table<int, int, std::less<int>, my_compare<int>,
std::hash<int>, my_hash<int>, std::equal_to<int>,
- my_equal<int>, allocator<int>,
- allocator<std::pair<const int, int>>>::value,
+ my_equal<int>, std::allocator<int>,
+ std::allocator<std::pair<const int, int>>>::value,
"");
static_assert(node_compatibility_table<
More information about the libcxx-commits
mailing list