Question on move constructor
Jonathan Wakely
jwakely.gcc@gmail.com
Mon Jan 28 19:51:00 GMT 2013
On 28 January 2013 18:16, Graziano Servizi <Graziano.Servizi@bo.infn.it> 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!
>
>
> I'm sorry; I made a mistake: it was the DESTRUCTOR (which IS provided) that
> needed to be noexcept-ed. On my system, if I didn't so, there are
> 3 moves and 3 copies (as you said), while with a noexcept DESTRUCTOR no copy
> occurs: only 6 moves.
Ah yes, with GCC 4.7 that is necessary.
I was testing with GCC trunk which has implicit noexcept on
destructors (as required by C++11)
More information about the Gcc-help
mailing list