1 // P1401R5: Narrowing contextual conversions to bool
2 // { dg-do compile { target c++11 } }
4 void f() noexcept(sizeof(char[2])); // { dg-error "narrowing" } conversion of value 2 to type bool
5 void g() noexcept(sizeof(char)); // OK, conversion of value 1 to type bool is non-narrowing
7 #if __cpp_conditional_explicit
9 explicit(sizeof(char[2])) S(char); // { dg-error "narrowing" "" { target c++20 } }
10 explicit(sizeof(char)) S(bool); // OK, conversion of value 1 to type bool is non-narrowing
14 static_assert(sizeof(int[2]), ""); // OK, narrowing allowed
16 #if __cpp_if_constexpr
19 if constexpr (sizeof(int[2])) // OK, narrowing allowed