This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Question on move constructor
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Graziano Servizi <Graziano dot Servizi at bo dot infn dot it>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Mon, 28 Jan 2013 17:28:14 +0000
- Subject: Re: Question on move constructor
- References: <5106B1AC.6050606@bo.infn.it>
On 28 January 2013 17:13, Graziano Servizi wrote:
>
> However specifying "noexcept" turns out to be necessary at least for the
> default constructor, otherwise no "move" operation is performed (on my
> system). Saying this I refer to the code I sent you in my early message.
> May be this is due to the instantiation of "v" in the first line of main?
> Did you ever meet such a situation before?
No, I don't see how it's possible.
The code in your first message has no default constructor, so I don't
understand how making a non-existent constructor noexcept can change
anything!
In the file "my_output.txt" you showed move operations like this one:
In MemoryBlock(MemoryBlock&&). length = 25. Moving resource.
If I run that code I get the same output, three moves, three copies.
If I add 'noexcept' to the move constructor and move assignment
operator then I get six moves and no copies.