From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 89A1E38582A4; Fri, 17 Mar 2023 20:35:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89A1E38582A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1679085338; bh=GpnDI4JUIJ3TsaMINk+fA3YuFpdHh2Z5D1TbMKdX4b0=; h=From:To:Subject:Date:From; b=mCSUe5I4ASRdOoGLcKF5ZgzuGohDyt/g/sXSTlD2vc1SqMMIrcp6MlS5SvmVJDE0o FkYKtwKm7U7ZMFZPFBGkgac0gjNtO3icX7O6V3+fCkT8hOt2MIgOfx76QJ/5DWZ18K LAzJZpxbFI91wFyVsLMWV2XDQHP/WPDpVe+3KR00= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r13-6741] libstdc++: Add const to hash>::operator() [PR109165] X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: ae7190e345a8d80310835cb83b3b41ef2aeb0d37 X-Git-Newrev: c48be8298c27143c1a684c0cb9689c88d16f4b49 Message-Id: <20230317203538.89A1E38582A4@sourceware.org> Date: Fri, 17 Mar 2023 20:35:38 +0000 (GMT) List-Id: https://gcc.gnu.org/g:c48be8298c27143c1a684c0cb9689c88d16f4b49 commit r13-6741-gc48be8298c27143c1a684c0cb9689c88d16f4b49 Author: Jonathan Wakely Date: Fri Mar 17 11:39:55 2023 +0000 libstdc++: Add const to hash>::operator() [PR109165] libstdc++-v3/ChangeLog: PR libstdc++/109165 * include/std/coroutine (hash<>::operator()): Add const. * testsuite/18_support/coroutines/hash.cc: New test. Diff: --- libstdc++-v3/include/std/coroutine | 2 +- .../testsuite/18_support/coroutines/hash.cc | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/libstdc++-v3/include/std/coroutine b/libstdc++-v3/include/std/coroutine index f6e65566f10..b0ca18949db 100644 --- a/libstdc++-v3/include/std/coroutine +++ b/libstdc++-v3/include/std/coroutine @@ -345,7 +345,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct hash> { size_t - operator()(const coroutine_handle<_Promise>& __h) noexcept + operator()(const coroutine_handle<_Promise>& __h) const noexcept { return reinterpret_cast(__h.address()); } diff --git a/libstdc++-v3/testsuite/18_support/coroutines/hash.cc b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc new file mode 100644 index 00000000000..68e5e640477 --- /dev/null +++ b/libstdc++-v3/testsuite/18_support/coroutines/hash.cc @@ -0,0 +1,22 @@ +// { dg-options "-std=gnu++2a" } +// { dg-do run { target c++2a } } + +#include +#include + +void +test01() +{ + std::hash h; + std::size_t v = h(std::noop_coroutine()); + + const auto& ch = h; + std::size_t v2 = h(std::noop_coroutine()); // PR libstdc++/109165 + + VERIFY( v2 == v ); +} + +int main() +{ + test01(); +}