17 Mar
2015
17 Mar
'15
10:58 p.m.
Steven Watanabe wrote:
One of these has to fail:
int ref(int&); int rref(int&&);
boost::function
f1(&ref); boost::function f2(&rref); I don't think there's any strong reason to support one over the other, so it's probably best to allow f1, since it used to be supported before rvalue references.
The rationale for supporting f1 was that void f1( int x ) { return ref( x ); } works, and this is what boost::function was, conceptually, trying to provide. Of course, this decision to allow f1(&ref) was made before rvalue references. Nowadays one would argue that rref should be free to pilfer the argument for efficiency.