diff --git a/libcxx/docs/Cxx2aStatus.rst b/libcxx/docs/Cxx2aStatus.rst --- a/libcxx/docs/Cxx2aStatus.rst +++ b/libcxx/docs/Cxx2aStatus.rst @@ -40,7 +40,7 @@ .. 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 `__. .. [#note-P0619] P0619: Only ``std::allocator`` part is implemented. diff --git a/libcxx/include/__node_handle b/libcxx/include/__node_handle --- a/libcxx/include/__node_handle +++ b/libcxx/include/__node_handle @@ -10,6 +10,54 @@ #ifndef _LIBCPP___NODE_HANDLE #define _LIBCPP___NODE_HANDLE +/* + +template +class node-handle { +public: + using value_type = see below; // not present for map containers + using key_type = see below; // not present for set containers + using mapped_type = see below; // not present for set containers + using allocator_type = see below; + +private: + using container_node_type = unspecified; // exposition only + using ator_traits = allocator_traits; // exposition only + + typename ator_traits::template + rebind_traits::pointer ptr_; // exposition only + optional alloc_; // exposition only + +public: + // [container.node.cons], constructors, copy, and assignment + constexpr node-handle() noexcept : ptr_(), alloc_() {} + node-handle(node-handle&&) noexcept; + node-handle& operator=(node-handle&&); + + // [container.node.dtor], destructor + ~node-handle(); + + // [container.node.observers], observers + value_type& value() const; // not present for map containers + key_type& key() const; // not present for set containers + mapped_type& mapped() const; // not present for set containers + + allocator_type get_allocator() const; + explicit operator bool() const noexcept; + [[nodiscard]] bool empty() const noexcept; // nodiscard since C++20 + + // [container.node.modifiers], modifiers + void swap(node-handle&) + noexcept(ator_traits::propagate_on_container_swap::value || + ator_traits::is_always_equal::value); + + friend void swap(node-handle& x, node-handle& y) noexcept(noexcept(x.swap(y))) { + x.swap(y); + } +}; + +*/ + #include <__config> #include #include diff --git a/libcxx/test/std/containers/container.node/node_handle.empty.nodiscard.verify.cpp b/libcxx/test/std/containers/container.node/node_handle.empty.nodiscard.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/containers/container.node/node_handle.empty.nodiscard.verify.cpp @@ -0,0 +1,42 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// #include +// #include +// #include +// #include + +// class node-handle; +// [[nodiscard]] bool empty() const noexcept; // nodiscard since C++20 + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +#include +#include +#include +#include + +#include "test_macros.h" + +template +void test_one(Container c) { + auto n = c.extract(c.begin()); + n.empty(); // expected-warning 8{{ignoring return value of function declared with 'nodiscard' attribute}} +} + +void test() { + test_one(std::set{1}); + test_one(std::multiset{1}); + test_one(std::map{{1, 1}}); + test_one(std::multimap{{1, 1}}); + test_one(std::unordered_set{1}); + test_one(std::unordered_multiset{1}); + test_one(std::unordered_map{{1, 1}}); + test_one(std::unordered_multimap{{1, 1}}); +}