
Jeffrey Lee Hellrung, Jr.-2 wrote:
I meant to explicitly ask whether the following are equivalent:
bind(T)& x bind(T&) x
[...]
No, they are not. bind(T)& x binds by reference so a change to x within the local scope will reflect to x in the enclosing scope. bind(T&) x binds by value so a change to x within the local scope will /not/ reflect to x in the enclosing scope. int x = 0; int& r = x; int y = 0; int& s = y; BOOST_LOCAL_BLOCK(bind(int&) r, bind(int&)& s) { // Only s bind by ref. r = -1; // Does not affect enclosing scope. s = -1; // Affects enclosing scope. } BOOST_LOCAL_BLOCK_END assert(r == 0); // Not changed by local block. assert(s == -1); // Changed by local block. In bind(T&)& the outer reference is the one that applies to the variable binding. The inner reference only indicates what the original variable type is. --Lorenzo -- View this message in context: http://boost.2283326.n4.nabble.com/local-Help-for-the-Alternatives-section-t... Sent from the Boost - Dev mailing list archive at Nabble.com.