|
Boost Users : |
Subject: Re: [Boost-users] [move] differences between results in C++03 and C++11 modes
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2014-02-15 17:11:20
El 12/02/2014 2:34, Lee Clagett escribió:
> I recently wanted to write such a macro too. Objects marked with
> BOOST_MOVABLE_BUT_NOT_COPYABLE have to be returned with "return
> boost::move(temp)" or C++03 compilers try to use the private
> copy-constructor on temp. Doing a boost::move return prevents NRVO in
> C++03, and C++11 (according to the language purists and gcc 4.7.3). This
> macro would at least provide NRVO capabilities in C++11. I think C++03
> support for NRVO in this situation is foolish; boost::move would have to
> invoke a private copy-constructor on the user type and hope the compiler
> didn't generate a function call to it. The documentation doesn't list
> these limitations AFAIK.
I've committed a first implementation to the develop branch:
SHA-1: 062000ed68cecf59f29b99f5a6167529ea359979
* Added BOOST_MOVE_RET
[develop 062000e] Added BOOST_MOVE_RET
7 files changed, 496 insertions(+), 129 deletions(-)
create mode 100644 example/doc_move_return.cpp
create mode 100644 proj/vc7ide/doc_move_return.vcproj
Documentation is updated with the details. I also discovered that Visual
2010 and 2012 are non-conforming when returning movable-only values. I'm
sure this first version will have several bugs, but let me know if this
is a good starting point.
Best,
Ion
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net