
At Fri, 28 May 2010 19:32:45 +0200, Thomas Klimpel wrote:
David Abrahams wrote:
I'm talking about the BOOST_COPYABLE_AND_MOVABLE case. Most compilers won't do RVO for code written like "X X::create()".
You are claiming that some aspect of that signature causes RVO not to happen? What aspect?
I was talking about the signature, but about the way "X X::create()" was written:
X X::create() { X x; return x; // passing value form static memeber-fn }
A static member function is just a function to the compiler. AFAIK, the only compiler in recent memory that doesn't have NRVO (yet) is Clang. And they're working on it. What compiler are you talking about?
The expectation that the statement "return x;" will benefit from RVO might not be justified here. Writing "return boost::move(x);" might actually be a good idea.
There are other scenarios where NRVO won't go into effect and return boost::move(x) is warranted, X create(bool which) { X a("foo"); X b("bar"); return which ? a : b; } but I don't see anything like that in this case. -- Dave Abrahams Meet me at BoostCon: http://www.boostcon.com BoostPro Computing http://www.boostpro.com