[Development] Move ctors for q_declare_shared types

Marc Mutz marc.mutz at kdab.com
Fri Jun 26 19:23:58 CEST 2015


On Friday 26 June 2015 16:52:16 Gunnar Roth wrote:
> Hi Marc
> Gesendet: Freitag, 26. Juni 2015 um 17:25 Uhr
>  Von: "Marc Mutz" <marc.mutz at kdab.com>
>  An: development at qt-project.org
>  Betreff: Re: [Development] Move ctors for q_declare_shared types
>  
> Marc are you from the future ? Or is just your  clock wrong ?

Clock, ever since laptop ran out of battery once it resets to an hour later on 
each syspend. I have given up for now.

> > >> According to the fundamental C++
> >> 
>  > > principle "Don't pay for what you don't use", not clearing target is
>  > > the correct thing to do.
> 
>  
> You are sure that principle can be applied here? IMO this means that no
> feature should be added to the language , which adds a load to other
> features.

This has been the case for virtually all features with the notable exception 
of exceptions, yes.

> For exmple adding move constructors should not make copy
> constructors slower.

Why would it?

> IMHO i find it very unexspected that after f(std::move(a)); 
> a can be non-empty.

It cannot. That's the move constructor, not the move assignment operator. This 
thread is about the move constructor, but unfortunately was highjacked for 
talk about the move assignment operator.

> I actually thought  there is a rule for && parameter
> functions, to make these empty. But maybe  there is not. At least Scott
> Meyers seems to have a similar opinion
> http://scottmeyers.blogspot.de/2014/06/the-drawbacks-of-implementing-move.
> html 

As you can see from the comments, I disagree with Scott on this one :)

> Wyh can you do this inline?  
>  QFoo &operator=(QFoo &&other) { swap(other);QFoo<>().swap(other); return
> *this; } would not work ?

It would. But you would have made a previously fully inline function call a 
non-inline one. You might as well copy, then (assuming we're still talking 
about implictly shared classes).

Thanks,
Marc

-- 
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt Experts



More information about the Development mailing list