Skip to content
Snippets Groups Projects
Commit c48be829 authored by Jonathan Wakely's avatar Jonathan Wakely
Browse files

libstdc++: Add const to hash<coroutine_handle<P>>::operator() [PR109165]

libstdc++-v3/ChangeLog:

	PR libstdc++/109165
	* include/std/coroutine (hash<>::operator()): Add const.
	* testsuite/18_support/coroutines/hash.cc: New test.
parent ae7190e3
No related branches found
No related tags found
No related merge requests found
...@@ -345,7 +345,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION ...@@ -345,7 +345,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
struct hash<coroutine_handle<_Promise>> struct hash<coroutine_handle<_Promise>>
{ {
size_t size_t
operator()(const coroutine_handle<_Promise>& __h) noexcept operator()(const coroutine_handle<_Promise>& __h) const noexcept
{ {
return reinterpret_cast<size_t>(__h.address()); return reinterpret_cast<size_t>(__h.address());
} }
......
// { dg-options "-std=gnu++2a" }
// { dg-do run { target c++2a } }
#include <coroutine>
#include <testsuite_hooks.h>
void
test01()
{
std::hash<std::noop_coroutine_handle> 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();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment