| 1 |
// PR c++/80691 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
|
| 4 |
struct true_type { static constexpr bool value = true; }; |
| 5 |
struct false_type { static constexpr bool value = false; }; |
| 6 |
template<typename...> using void_t = void; |
| 7 |
template<typename T> T&& declval(); |
| 8 |
|
| 9 |
template<typename T, typename U, typename = void> |
| 10 |
struct is_nonnarrowing_conversion : false_type {}; |
| 11 |
|
| 12 |
template<typename T, typename U> |
| 13 |
struct is_nonnarrowing_conversion<T, U, |
| 14 |
void_t<decltype(T{ declval<U>() })>> : true_type {}; |
| 15 |
|
| 16 |
template<typename T> |
| 17 |
class wrapper |
| 18 |
{ |
| 19 |
public: |
| 20 |
wrapper(T) {} |
| 21 |
}; |
| 22 |
|
| 23 |
static_assert(!is_nonnarrowing_conversion<int, float>::value, ""); |
| 24 |
static_assert(!is_nonnarrowing_conversion<wrapper<int>, float>::value, ""); |