From d58daf94337f5e06d867c64869f2763e73f01df2 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Sat, 12 Oct 2013 22:49:17 +0000 Subject: [PATCH] LWG Issue 2097: packaged_task constructors should be constrained llvm-svn: 192544 --- libcxx/include/future | 40 +++++++++++++++++-- .../futures.task.members/ctor1.fail.cpp | 29 ++++++++++++++ .../futures.task.members/ctor2.fail.cpp | 30 ++++++++++++++ .../thread.thread.constr/constr.fail.cpp | 26 ++++++++++++ 4 files changed, 121 insertions(+), 4 deletions(-) create mode 100644 libcxx/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp create mode 100644 libcxx/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp create mode 100644 libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp diff --git a/libcxx/include/future b/libcxx/include/future index 334eaeb5e1f9..2d969df1b539 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -2013,10 +2013,26 @@ public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} - template + template ::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} - template + template ::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), @@ -2128,10 +2144,26 @@ public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} - template + template ::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} - template + template ::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), diff --git a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp new file mode 100644 index 000000000000..45048b747f7a --- /dev/null +++ b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor1.fail.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// class packaged_task +// template +// packaged_task(F&& f); +// These constructors shall not participate in overload resolution if +// decay::type is the same type as std::packaged_task. + +#include +#include + +struct A {}; +typedef std::packaged_task PT; +typedef volatile std::packaged_task VPT; + + +int main() +{ + PT p { VPT{} }; +} diff --git a/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp new file mode 100644 index 000000000000..e81adfa6dcd5 --- /dev/null +++ b/libcxx/test/thread/futures/futures.tas/futures.task.members/ctor2.fail.cpp @@ -0,0 +1,30 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// class packaged_task +// template +// explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f); +// These constructors shall not participate in overload resolution if +// decay::type is the same type as std::packaged_task. + +#include +#include + +#include "../../test_allocator.h" + +struct A {}; +typedef std::packaged_task PT; +typedef volatile std::packaged_task VPT; + +int main() +{ + PT p { std::allocator_arg_t{}, test_allocator{}, VPT {}}; +} diff --git a/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp new file mode 100644 index 000000000000..a331add96263 --- /dev/null +++ b/libcxx/test/thread/thread.threads/thread.thread.class/thread.thread.constr/constr.fail.cpp @@ -0,0 +1,26 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// + +// class thread +// template ::type is the same type as std::thread. + + +#include +#include + +int main() +{ + volatile std::thread t1; + std::thread t2 ( t1, 1, 2.0 ); +}