c++ - Particular form of bind temporary to const reference has no effect -
given
struct { void a(void) { std::cout << "a" << std::endl; } }; const &a = a(); /* make copy of , bind */ const &b(a()); /* nothing */ a.a(); /* prints */ b.a(); /* error, same if b doesn't exist */
why second form of "bind temporary const reference" seem equivalent no-op?
this case of most vexing parse, you're declaring function rather const reference a
.
you fix using c++11 uniform initialization:
const &b{a()};