// PR c++/113629 // { dg-do compile { target c++23 } } template constexpr bool is_lvalue = false; template constexpr bool is_lvalue = true; struct A { constexpr operator bool(this auto&& self) { return is_lvalue; } }; constexpr A a; static_assert(static_cast(a)); static_assert((bool)a); static_assert(!static_cast(A{})); static_assert(!(bool)A{}); struct B : A {}; constexpr B b; static_assert(static_cast(b)); static_assert((bool)b); static_assert(!static_cast(B{})); static_assert(!(bool)B{}); struct C { template explicit constexpr operator R(this T&&) { return is_lvalue; } }; constexpr C c; static_assert(static_cast(c)); static_assert((bool)c); static_assert(!static_cast(C{})); static_assert(!(bool)C{}); struct D { explicit constexpr operator bool(this const D&) { return true; } explicit constexpr operator bool(this const D&&) { return false; } }; constexpr D d; static_assert(static_cast(d)); static_assert((bool)d); static_assert(!static_cast(D{})); static_assert(!(bool)D{});