Skip to content

Commit 9d7ae0a

Browse files
committed
[libc++][NFC] Correct comment about P0600 missing node_handle bits
Differential Revision: https://reviews.llvm.org/D109027
1 parent 3557c7c commit 9d7ae0a

File tree

3 files changed

+67
-17
lines changed

3 files changed

+67
-17
lines changed

libcxx/docs/Status/Cxx20.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Paper Status
4040

4141
.. note::
4242

43-
.. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class], |sect|\ [mem.poly.allocator.class], and |sect|\ [container.node.overview].
43+
.. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class] and |sect|\ [mem.poly.allocator.class].
4444
.. [#note-P0966] P0966: It was previously erroneously marked as complete in version 8.0. See `bug 45368 <https://llvm.org/PR45368>`__.
4545
.. [#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.
4646
.. [#note-P0883] P0883: shared_ptr and floating-point changes weren't applied as they themselves aren't implemented yet.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// UNSUPPORTED: c++03, c++11, c++14, c++17
10+
11+
// Make sure the various node handles mark their .empty() method with
12+
// [[nodiscard]] starting with C++20
13+
14+
#include <map>
15+
#include <set>
16+
#include <unordered_map>
17+
#include <unordered_set>
18+
19+
void test() {
20+
{
21+
std::map<int, int>::node_type node;
22+
node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
23+
}
24+
{
25+
std::multimap<int, int>::node_type node;
26+
node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
27+
}
28+
{
29+
std::set<int> node;
30+
node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
31+
}
32+
{
33+
std::multiset<int> node;
34+
node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
35+
}
36+
{
37+
std::unordered_map<int, int> node;
38+
node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
39+
}
40+
{
41+
std::unordered_multimap<int, int> node;
42+
node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
43+
}
44+
{
45+
std::unordered_set<int> node;
46+
node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
47+
}
48+
{
49+
std::unordered_multiset<int> node;
50+
node.empty(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
51+
}
52+
}

libcxx/test/std/containers/container.node/node_handle.pass.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,27 @@
1515
#include "test_macros.h"
1616
#include "min_allocator.h"
1717

18-
using namespace std;
19-
2018
// [container.node.overview] Table 83.
2119
template <class K, class T, class C1, class C2, class H1, class H2, class E1, class E2, class A_set, class A_map>
2220
struct node_compatibility_table
2321
{
2422
static constexpr bool value =
25-
is_same_v<typename map<K, T, C1, A_map>::node_type, typename map<K, T, C2, A_map>::node_type> &&
26-
is_same_v<typename map<K, T, C1, A_map>::node_type, typename multimap<K, T, C2, A_map>::node_type> &&
27-
is_same_v<typename set<K, C1, A_set>::node_type, typename set<K, C2, A_set>::node_type> &&
28-
is_same_v<typename set<K, C1, A_set>::node_type, typename multiset<K, C2, A_set>::node_type> &&
29-
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> &&
30-
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> &&
31-
is_same_v<typename unordered_set<K, H1, E1, A_set>::node_type, typename unordered_set<K, H2, E2, A_set>::node_type> &&
32-
is_same_v<typename unordered_set<K, H1, E1, A_set>::node_type, typename unordered_multiset<K, H2, E2, A_set>::node_type>;
23+
std::is_same_v<typename std::map<K, T, C1, A_map>::node_type, typename std::map<K, T, C2, A_map>::node_type> &&
24+
std::is_same_v<typename std::map<K, T, C1, A_map>::node_type, typename std::multimap<K, T, C2, A_map>::node_type> &&
25+
std::is_same_v<typename std::set<K, C1, A_set>::node_type, typename std::set<K, C2, A_set>::node_type> &&
26+
std::is_same_v<typename std::set<K, C1, A_set>::node_type, typename std::multiset<K, C2, A_set>::node_type> &&
27+
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> &&
28+
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> &&
29+
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> &&
30+
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>;
3331
};
3432

3533
template <class T> struct my_hash
3634
{
3735
using argument_type = T;
38-
using result_type = size_t;
36+
using result_type = std::size_t;
3937
my_hash() = default;
40-
size_t operator()(const T&) const {return 0;}
38+
std::size_t operator()(const T&) const {return 0;}
4139
};
4240

4341
template <class T> struct my_compare
@@ -66,9 +64,9 @@ namespace std
6664
template <> struct hash<Static>
6765
{
6866
using argument_type = Static;
69-
using result_type = size_t;
67+
using result_type = std::size_t;
7068
hash() = default;
71-
size_t operator()(const Static&) const;
69+
std::size_t operator()(const Static&) const;
7270
};
7371
}
7472

@@ -82,8 +80,8 @@ static_assert(node_compatibility_table<
8280
static_assert(
8381
node_compatibility_table<int, int, std::less<int>, my_compare<int>,
8482
std::hash<int>, my_hash<int>, std::equal_to<int>,
85-
my_equal<int>, allocator<int>,
86-
allocator<std::pair<const int, int>>>::value,
83+
my_equal<int>, std::allocator<int>,
84+
std::allocator<std::pair<const int, int>>>::value,
8785
"");
8886

8987
static_assert(node_compatibility_table<

0 commit comments

Comments
 (0)