| 1 |
// PR c++/98620 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
namespace std { |
| 5 |
template<typename T> |
| 6 |
T&& declval() noexcept; |
| 7 |
|
| 8 |
template<bool B> |
| 9 |
struct bool_constant { |
| 10 |
static constexpr bool value = B; |
| 11 |
using type = bool_constant; |
| 12 |
}; |
| 13 |
using true_type = bool_constant<true>; |
| 14 |
using false_type = bool_constant<false>; |
| 15 |
}; |
| 16 |
|
| 17 |
template <typename T> |
| 18 |
struct TmpArray |
| 19 |
{ |
| 20 |
T arr[1]; |
| 21 |
}; |
| 22 |
|
| 23 |
template <typename Src, typename Dst, typename = void> |
| 24 |
struct is_non_narrowing_conversion : std::false_type |
| 25 |
{}; |
| 26 |
|
| 27 |
template <typename Src, typename Dst> |
| 28 |
struct is_non_narrowing_conversion< |
| 29 |
Src, Dst, |
| 30 |
decltype(void(TmpArray<Dst>{{ std::declval<Src>() }})) // { dg-bogus "missing initializer" } |
| 31 |
> : std::true_type |
| 32 |
{}; |
| 33 |
|
| 34 |
struct mystruct |
| 35 |
{ |
| 36 |
int a; |
| 37 |
void * b; |
| 38 |
}; |
| 39 |
|
| 40 |
void test_nok() |
| 41 |
{ |
| 42 |
is_non_narrowing_conversion<int&, mystruct>::type v; |
| 43 |
(void) v; |
| 44 |
} |