1. int&可以bind到A::g中的a,因为a是lvalue2. int& b = foo1(5)违法是因为foo1(5)是prvalue (purervalue)3. foo2在C++20及以前都编得过,但是return的reference是dangle的,去印出来是未定义行为。C++23 P2266R3开始,a作为return的operand是xvalue,不能被bound to non-const lvalue reference,int&改成int&&或const int&才编得过。
http://wg21.link/P2266R3