]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Make std::jthread support pointers to member functions [PR 100612]
authorJonathan Wakely <jwakely@redhat.com>
Thu, 20 May 2021 21:36:16 +0000 (22:36 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 1 Oct 2021 19:36:55 +0000 (20:36 +0100)
commit34e9407b3b4298bd587e0df2e0047679019b66cf
tree3421a67def4b876e75759a78354341efc795dc3d
parentb7e8fb5e48279ffa5f424e3dd0bb3dfcbe69f5d5
libstdc++: Make std::jthread support pointers to member functions [PR 100612]

This adds a non-standard extension to support initializing a
std::jthread with a pointer to a member function that expects a
stop_token to be added to the arguments. That use case is not supported
by C++20, because the stop_token would get added as the first argument,
which is where the object argument needs to be to invoke a pointer to
member function.

Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
libstdc++-v3/ChangeLog:

PR libstdc++/100612
* include/std/thread (__pmf_expects_stop_token): New variable
template to detect a pointer to member function that needs a
stop_token to be added to the arguments.
(jthread::__S_create): Use __pmf_expects_stop_token.
(jthread::__S_create_pmf): New function.
* testsuite/30_threads/jthread/100612.cc: New test.
libstdc++-v3/include/std/thread
libstdc++-v3/testsuite/30_threads/jthread/100612.cc [new file with mode: 0644]