PR libstdc++/84535 constrain std::thread constructor
commitfc9b80eac58c223b7e5fda46fd432bf21a098cde
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 May 2018 14:08:36 +0000 (3 14:08 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 3 May 2018 14:08:36 +0000 (3 14:08 +0000)
treef9749ffd105f6da70ff696ec7a8837ce916d1670
parentd0f163aa4da496c6ed8de683afd285c89c1f8934
PR libstdc++/84535 constrain std::thread constructor

The standard requires that the std::thread constructor is constrained so
it can't be called with a first argument of type std::thread. The
current implementation only meets that requirement if the constructor is
called with one argument, by using deleted overloads. This uses an
enable_if constraint to enforce the requirement for any number of
arguments.

Also add a static assertion to give a more readable error for invalid
arguments that cannot be invoked. Also simplify _Invoker to reduce the
error cascade for ill-formed instantiations with non-invocable
arguments.

PR libstdc++/84535
* include/std/thread (thread::__not_same): New SFINAE helper.
(thread::thread(_Callable&&, _Args&&...)): Add SFINAE constraint that
first argument is not a std::thread. Add static assertion to check
INVOKE expression is valid.
(thread::thread(thread&), thread::thread(const thread&&)): Remove.
(thread::_Invoke::_M_invoke, thread::_Invoke::operator()): Use
__invoke_result for return types and remove exception specifications.
* testsuite/30_threads/thread/cons/84535.cc: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@259893 138bc75d-0d04-0410-961f-82ee72b054a4
libstdc++-v3/ChangeLog
libstdc++-v3/include/std/thread
libstdc++-v3/testsuite/30_threads/thread/cons/84535.cc [new file with mode: 0644]