finding about move vs copy in C++

Jonathan Wakely jwakely.gcc@gmail.com
Wed Dec 31 10:18:00 GMT 2014


On 31 December 2014 at 08:19, Anthony Shipman wrote:
> Is there some command line option that will get the compiler to tell me which
> of a move or copy constructor, which of a move assignment or copy assignment
> it has chosen to do at each point in the source code?

Not specifically, no.

If you invoke g++ with -v it will show you the full cc1plus command it
runs, and you can run that yourself without the -quiet option, which
(among lots of other information) will print the name of each function
as it is compiled.

> That would make it much easier to ensure that moves are done when they are
> supposed to be.

Moves will be done when they're supposed to be done, according to the
rules of C++. If you mean moves are done when you *expect* them to be
done that's a different thing, as your expectations may be wrong  :-)

What exactly are you worried about, the compiler failing to perform
moves, or your code missing opportunities to move?

The former will very rarely be a problem, the latter can be solved by
understanding the language better.



More information about the Gcc-help mailing list