[Development] [API] homogenising pimpled value class copying and moving
Marc Mutz
marc.mutz at kdab.com
Tue May 8 16:57:47 CEST 2012
On Tuesday May 8 2012, Thiago Macieira wrote:
> On terça-feira, 8 de maio de 2012 15.22.55, Marc Mutz wrote:
> > I'm also giving each class a move constructor. There, the classes which
> > hold their pimpl in smart pointers create the problem[1] that the move
> > ctor cannot be inline. I'm tempted to remove the use of these in favour
> > of going back to naked pointers, which allow the move ctor to be inline.
> > Does anyone feel very strongly about that?
>
> Between a move constructor and QSharedDataPointer, I'd rather stay with the
> latter. It avoids the manual reference counting, which may include subtle
> errors.
The manual reference counting reduces to calling ref() in the copy ctor and
deref() || delete in the dtor, thanks to the copy-swap idiom.
> An alternative is to use C++11 extern template declarations alongside an
> export macro. It's a solution I had tried and worked in
> QDBusUnixFileDescriptor, using GCC's equivalent C++98 extension.
This doesn't sound like the code ends up inline, though. Do you have a change
set so I can look at it?
BC is only one reason to have the move ctor inline. The other is speed. Moving
should be blazingly fast, and jumping into a so/dll to perform it sounds like
premature pessimisation :)
Thanks,
Marc
--
Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
More information about the Development
mailing list