According to cppreference, bit-fields can only be captured by copy: https://en.cppreference.com/w/cpp/language/lambda. Period.
At the same time, one can see certain scenarios, e.g.:
struct U {
int i : 4;
};
constexpr int foo() {
const auto & [y] = U{5};
return [&y = y]() { return y; }();
}
static_assert( foo() == 5 );
where both GCC and Clang permit capture of bit-fields by reference even during evaluation of constant expressions. Online demo: https://gcc.godbolt.org/z/bcbqcGKd7
Are there any exceptions not mentioned in cppreference or proposals to future C++ standards, which legalize capture of bit-fields by reference?