libstdc++: Add static assertions to futures and promises [LWG 3458]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 22 Jul 2020 19:10:38 +0000 (20:10 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 22 Jul 2020 19:11:00 +0000 (20:11 +0100)
commit1f53367fb5f16985e82c39f56368b956292cf86c
tree557ab60dd23a3f0fa24b28f4f1d6ac0277ef50ed
parente55ba804d3b8de86a430a8a5553dfc1ad06daa74
libstdc++: Add static assertions to futures and promises [LWG 3458]

LWG recently decided it should be ill-formed to instantiate std::future
and std::shared_future for types that can't be returned from a function.
This adds static assertions to enforce it (std::future already failed,
but this makes the error more understandable).

LWG 3466 extends that to std::promise. The actual constraint is that
t.~T() is well-formed for the primary template, but rejecting arrays and
functions as done for futures matches that condition.

libstdc++-v3/ChangeLog:

* include/std/future (future, shared_future, promise): Add
static assertions to the primary template to reject array and
function types.
* testsuite/30_threads/future/requirements/lwg3458.cc: New test.
* testsuite/30_threads/promise/requirements/lwg3466.cc: New test.
* testsuite/30_threads/shared_future/requirements/lwg3458.cc: New test.
libstdc++-v3/include/std/future
libstdc++-v3/testsuite/30_threads/future/requirements/lwg3458.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/promise/requirements/lwg3466.cc [new file with mode: 0644]
libstdc++-v3/testsuite/30_threads/shared_future/requirements/lwg3458.cc [new file with mode: 0644]