LWG Issue 2097: packaged_task constructors should be constrained
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@192544 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
206ce1faaf
commit
5f2d5b95e6
@ -2013,10 +2013,26 @@ public:
|
|||||||
// construction and destruction
|
// construction and destruction
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
packaged_task() _NOEXCEPT : __p_(nullptr) {}
|
packaged_task() _NOEXCEPT : __p_(nullptr) {}
|
||||||
template <class _Fp>
|
template <class _Fp,
|
||||||
|
class = typename enable_if
|
||||||
|
<
|
||||||
|
!is_same<
|
||||||
|
typename decay<_Fp>::type,
|
||||||
|
packaged_task
|
||||||
|
>::value
|
||||||
|
>::type
|
||||||
|
>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
|
explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
|
||||||
template <class _Fp, class _Allocator>
|
template <class _Fp, class _Allocator,
|
||||||
|
class = typename enable_if
|
||||||
|
<
|
||||||
|
!is_same<
|
||||||
|
typename decay<_Fp>::type,
|
||||||
|
packaged_task
|
||||||
|
>::value
|
||||||
|
>::type
|
||||||
|
>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
|
explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
|
||||||
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
|
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
|
||||||
@ -2128,10 +2144,26 @@ public:
|
|||||||
// construction and destruction
|
// construction and destruction
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
packaged_task() _NOEXCEPT : __p_(nullptr) {}
|
packaged_task() _NOEXCEPT : __p_(nullptr) {}
|
||||||
template <class _Fp>
|
template <class _Fp,
|
||||||
|
class = typename enable_if
|
||||||
|
<
|
||||||
|
!is_same<
|
||||||
|
typename decay<_Fp>::type,
|
||||||
|
packaged_task
|
||||||
|
>::value
|
||||||
|
>::type
|
||||||
|
>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
|
explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {}
|
||||||
template <class _Fp, class _Allocator>
|
template <class _Fp, class _Allocator,
|
||||||
|
class = typename enable_if
|
||||||
|
<
|
||||||
|
!is_same<
|
||||||
|
typename decay<_Fp>::type,
|
||||||
|
packaged_task
|
||||||
|
>::value
|
||||||
|
>::type
|
||||||
|
>
|
||||||
_LIBCPP_INLINE_VISIBILITY
|
_LIBCPP_INLINE_VISIBILITY
|
||||||
explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
|
explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f)
|
||||||
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
|
: __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)),
|
||||||
|
@ -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.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// <future>
|
||||||
|
|
||||||
|
// class packaged_task<R(ArgTypes...)>
|
||||||
|
// template <class F>
|
||||||
|
// packaged_task(F&& f);
|
||||||
|
// These constructors shall not participate in overload resolution if
|
||||||
|
// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
|
||||||
|
|
||||||
|
#include <future>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
struct A {};
|
||||||
|
typedef std::packaged_task<A(int, char)> PT;
|
||||||
|
typedef volatile std::packaged_task<A(int, char)> VPT;
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
PT p { VPT{} };
|
||||||
|
}
|
@ -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.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// <future>
|
||||||
|
|
||||||
|
// class packaged_task<R(ArgTypes...)>
|
||||||
|
// template <class F, class Allocator>
|
||||||
|
// explicit packaged_task(allocator_arg_t, const Allocator& a, F&& f);
|
||||||
|
// These constructors shall not participate in overload resolution if
|
||||||
|
// decay<F>::type is the same type as std::packaged_task<R(ArgTypes...)>.
|
||||||
|
|
||||||
|
#include <future>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
#include "../../test_allocator.h"
|
||||||
|
|
||||||
|
struct A {};
|
||||||
|
typedef std::packaged_task<A(int, char)> PT;
|
||||||
|
typedef volatile std::packaged_task<A(int, char)> VPT;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
PT p { std::allocator_arg_t{}, test_allocator<A>{}, VPT {}};
|
||||||
|
}
|
@ -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.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// <thread>
|
||||||
|
|
||||||
|
// class thread
|
||||||
|
// template <class _Fp, class ..._Args,
|
||||||
|
// explicit thread(_Fp&& __f, _Args&&... __args);
|
||||||
|
// This constructor shall not participate in overload resolution
|
||||||
|
// if decay<F>::type is the same type as std::thread.
|
||||||
|
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
volatile std::thread t1;
|
||||||
|
std::thread t2 ( t1, 1, 2.0 );
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user