| 1 |
// PR c++/56039 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
template <bool> struct BoolSink { typedef void type; }; |
| 5 |
|
| 6 |
template <typename T, typename U> |
| 7 |
struct AddRvalueReferenceImpl { typedef T type; }; |
| 8 |
|
| 9 |
template <typename T> |
| 10 |
struct AddRvalueReferenceImpl<T, typename BoolSink<false && |
| 11 |
[] { // { dg-error "lambda" "" { target c++17_down } } |
| 12 |
extern void tref(T&&); |
| 13 |
}>::type> { |
| 14 |
typedef T &&type; |
| 15 |
}; |
| 16 |
|
| 17 |
template <typename T> |
| 18 |
struct AddRvalueReference : AddRvalueReferenceImpl<T, void> { }; |
| 19 |
|
| 20 |
namespace ImplHelpers { |
| 21 |
template <typename T> |
| 22 |
typename AddRvalueReference<T>::type create(void); |
| 23 |
} |
| 24 |
|
| 25 |
template <typename T, typename U, typename ...Args> |
| 26 |
struct IsConstructibleImpl { enum { value = 0 }; }; |
| 27 |
|
| 28 |
template <typename T, typename ...Args> |
| 29 |
struct IsConstructibleImpl<T, typename BoolSink<false && |
| 30 |
[] { T t( ::ImplHelpers::create<Args>() ...); } // { dg-error "" } |
| 31 |
>::type, Args ...> { |
| 32 |
enum { value = 1 }; |
| 33 |
}; |
| 34 |
|
| 35 |
template <typename T, typename ...Args> |
| 36 |
struct IsConstructible : IsConstructibleImpl<T, void, Args ...> { }; |
| 37 |
|
| 38 |
struct DestroyMe { |
| 39 |
~DestroyMe() = delete; |
| 40 |
}; |
| 41 |
|
| 42 |
static_assert(+IsConstructible<int>::value, "error"); |
| 43 |
static_assert(!IsConstructible<void>::value, "error"); |
| 44 |
static_assert(+IsConstructible<int [1]>::value, "error"); |
| 45 |
static_assert(!IsConstructible<DestroyMe>::value, "error"); |
| 46 |
static_assert(!IsConstructible<int *, char *>::value, "error"); |
| 47 |
|
| 48 |
static_assert(+IsConstructible<int &&, int>::value, "error"); |
| 49 |
static_assert(!IsConstructible<int &&, int &>::value, "error"); |
| 50 |
static_assert(+IsConstructible<int &&, int &&>::value, "error"); |
| 51 |
|
| 52 |
// { dg-prune-output "expected" } |
| 53 |
// { dg-prune-output "does not name a class" } |
| 54 |
// { dg-prune-output "static assertion" } |
| 55 |
// { dg-prune-output "template argument . is invalid" } |