Skip to content

Commit 5fa8f23

Browse files
committed
Improved
1 parent 358bd94 commit 5fa8f23

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

libcxx/test/libcxx/diagnostics/map.nodiscard.verify.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,18 @@
1515
#include "test_macros.h"
1616

1717
#if TEST_STD_VER >= 14
18-
template <typename T>
1918
struct TransparentKey {
20-
explicit operator T() const;
19+
explicit operator int() const;
2120
};
2221

2322
struct TransparentCompare {
2423
using is_transparent = void; // This makes the comparator transparent
2524

26-
template <typename T>
27-
bool operator()(const T&, const TransparentKey<T>&) const;
25+
bool operator()(const int&, const TransparentKey&) const;
2826

29-
template <typename T>
30-
bool operator()(const TransparentKey<T>&, const T&) const;
27+
bool operator()(const TransparentKey<T>&, const int&) const;
3128

32-
template <typename T>
33-
bool operator()(const T&, const T&) const;
29+
bool operator()(const int&, const int&) const;
3430
};
3531
#endif
3632

@@ -89,7 +85,7 @@ void test() {
8985
std::map<int, int, TransparentCompare> tm;
9086
const std::map<int, int, TransparentCompare> ctm{};
9187

92-
TransparentKey<int> tkey;
88+
TransparentKey tkey;
9389

9490
tm.find(tkey); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
9591
ctm.find(tkey); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}

0 commit comments

Comments
 (0)