view gcc/testsuite/g++.dg/cpp0x/narrowing1.C @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
line wrap: on
line source

// PR c++/80691
// { dg-do compile { target c++11 } }

struct true_type { static constexpr bool value = true; };
struct false_type { static constexpr bool value = false; };
template<typename...> using void_t = void;
template<typename T> T&& declval();

template<typename T, typename U, typename = void>
struct is_nonnarrowing_conversion : false_type {};

template<typename T, typename U>
struct is_nonnarrowing_conversion<T, U,
    void_t<decltype(T{ declval<U>() })>> : true_type {};

template<typename T>
class wrapper
{
public:
    wrapper(T) {}
};

static_assert(!is_nonnarrowing_conversion<int, float>::value, "");
static_assert(!is_nonnarrowing_conversion<wrapper<int>, float>::value, "");