// P0847R7 // { dg-do compile { target c++23 } } // decltype((x)) and decltype(x) in explicit object lambda template inline constexpr bool is_const_v = false; template inline constexpr bool is_const_v = true; template inline constexpr bool is_lvalue_ref = false; template inline constexpr bool is_lvalue_ref = true; void non_dep() { int n = 0; int const c = 0; // value auto f0_value = [=](this Self){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_value(); f0_value.operator()(); auto f1_value = [&](this Self){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_value(); f1_value.operator()(); auto f2_value = [n, c](this Self){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_value(); f2_value.operator()(); auto f3_value = [&n, &c](this Self){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_value(); f3_value.operator()(); auto f4_value = [](this Self){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_value(); f4_value.operator()(); // ref auto f0_ref = [=](this Self&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_ref(); f0_ref.operator()(); static_cast(f0_ref)(); auto f1_ref = [&](this Self&){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_ref(); f1_ref.operator()(); static_cast(f1_ref)(); auto f2_ref = [n, c](this Self&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_ref(); f2_ref.operator()(); static_cast(f2_ref)(); auto f3_ref = [&n, &c](this Self&){ static_assert(__is_same(decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_ref(); f3_ref.operator()(); static_cast(f3_ref)(); auto f4_ref = [](this Self&){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_ref(); f4_ref.operator()(); static_cast(f4_ref)(); // const value auto f0_const_value = [=](this Self const){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_const_value(); auto f1_const_value = [&](this Self const){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_const_value(); auto f2_const_value = [n, c](this Self const){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_const_value(); auto f3_const_value = [&n, &c](this Self const){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_const_value(); auto f4_const_value = [](this Self const){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_const_value(); // const ref auto f0_const_ref = [=](this Self const&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_const_ref(); auto f1_const_ref = [&](this Self const&){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_const_ref(); auto f2_const_ref = [n, c](this Self const&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_const_ref(); auto f3_const_ref = [&n, &c](this Self const&){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_const_ref(); auto f4_const_ref = [](this Self const&){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_const_ref(); } template void dep0() { int n = 0; int const c = 0; // value auto f0_value = [=](this Self){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_value(); f0_value.template operator()(); auto f1_value = [&](this Self){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_value(); f1_value.template operator()(); auto f2_value = [n, c](this Self){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_value(); f2_value.template operator()(); auto f3_value = [&n, &c](this Self){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_value(); f3_value.template operator()(); auto f4_value = [](this Self){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_value(); f4_value.template operator()(); // ref auto f0_ref = [=](this Self&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_ref(); f0_ref.template operator()(); static_cast(f0_ref)(); auto f1_ref = [&](this Self&){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_ref(); f1_ref.template operator()(); static_cast(f1_ref)(); auto f2_ref = [n, c](this Self&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_ref(); f2_ref.template operator()(); static_cast(f2_ref)(); auto f3_ref = [&n, &c](this Self&){ static_assert(__is_same(decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_ref(); f3_ref.template operator()(); static_cast(f3_ref)(); auto f4_ref = [](this Self&){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_ref(); f4_ref.template operator()(); static_cast(f4_ref)(); // const value auto f0_const_value = [=](this Self const){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_const_value(); auto f1_const_value = [&](this Self const){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_const_value(); auto f2_const_value = [n, c](this Self const){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_const_value(); auto f3_const_value = [&n, &c](this Self const){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_const_value(); auto f4_const_value = [](this Self const){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_const_value(); // const ref auto f0_const_ref = [=](this Self const&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_const_ref(); auto f1_const_ref = [&](this Self const&){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_const_ref(); auto f2_const_ref = [n, c](this Self const&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_const_ref(); auto f3_const_ref = [&n, &c](this Self const&){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_const_ref(); auto f4_const_ref = [](this Self const&){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_const_ref(); } // dep1 uses the template parameter template void dep1() { T n = 0; T const c = 0; // value auto f0_value = [=](this Self){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_value(); f0_value.template operator()(); auto f1_value = [&](this Self){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_value(); f1_value.template operator()(); auto f2_value = [n, c](this Self){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_value(); f2_value.template operator()(); auto f3_value = [&n, &c](this Self){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_value(); f3_value.template operator()(); auto f4_value = [](this Self){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_value(); f4_value.template operator()(); // ref auto f0_ref = [=](this Self&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_ref(); f0_ref.template operator()(); static_cast(f0_ref)(); auto f1_ref = [&](this Self&){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_ref(); f1_ref.template operator()(); static_cast(f1_ref)(); auto f2_ref = [n, c](this Self&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v == is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_ref(); f2_ref.template operator()(); static_cast(f2_ref)(); auto f3_ref = [&n, &c](this Self&){ static_assert(__is_same(decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_ref(); f3_ref.template operator()(); static_cast(f3_ref)(); auto f4_ref = [](this Self&){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_ref(); f4_ref.template operator()(); static_cast(f4_ref)(); // const value auto f0_const_value = [=](this Self const){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_const_value(); auto f1_const_value = [&](this Self const){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_const_value(); auto f2_const_value = [n, c](this Self const){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_const_value(); auto f3_const_value = [&n, &c](this Self const){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_const_value(); auto f4_const_value = [](this Self const){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_const_value(); // const ref auto f0_const_ref = [=](this Self const&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f0_const_ref(); auto f1_const_ref = [&](this Self const&){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f1_const_ref(); auto f2_const_ref = [n, c](this Self const&){ static_assert(is_lvalue_ref, "decltype((n)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((n)))>, // { dg-bogus {static assertion failed: qualification of decltype\(\(n\)\) does not match qualification of Self} } "qualification of decltype((n)) does not match qualification of Self"); static_assert(__is_same (__remove_cvref (decltype((n))), int), "decltype((n)) is not an int"); static_assert(__is_same (decltype(n), int)); static_assert(is_lvalue_ref, "decltype((c)) is not an lvalue ref"); static_assert(is_const_v<__remove_reference (decltype((c)))>, "qualification of decltype((c)) is not const"); static_assert(__is_same (__remove_cvref (decltype((c))), int), "decltype((c)) is not an int"); static_assert(__is_same (decltype(c), int const)); }; f2_const_ref(); auto f3_const_ref = [&n, &c](this Self const&){ static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((c)), int const&)); static_assert(__is_same (decltype(c), int const)); }; f3_const_ref(); auto f4_const_ref = [](this Self const&){ static_assert(__is_same (decltype(n), int)); static_assert(__is_same (decltype((n)), int&)); static_assert(__is_same (decltype(c), int const)); static_assert(__is_same (decltype((c)), int const&)); }; f4_const_ref(); } void instantiate_dep() { dep0(); dep1(); }