about kde4's smart pointer

Michel Hermier michel.hermier at gmail.com
Wed Oct 4 08:47:15 BST 2006

If I remember well, this problem is visible due to an *hole* in the C++ grammar.
How to interpret Foo foo = new Bar;
Some compiler (like gcc) change this as Foo foo(new Bar); for me this
is a mistake and should be interpreted as Foo foo; foo = new Bar; .
While I agree, it should do the same thing, it's not an obligation to
do so. So if the user really meant to do Foo foo(new Bar); it as to
write it, else it's the 2 steps construction.

2006/10/4, Cyrille Berger <cberger at cberger.net>:
> > Or dynamicCast, if you're going the other way.
> Well without smart pointers, I can do KisDevice* device = new
> KisPaintDevice(); And as I think smart pointers should behave like C++
> pointers I should be able to do it. Of course, KisPaintDeviceSP pd = device;
> shouldn't be possible.
> --
> --- Cyrille Berger ---

More information about the kde-core-devel mailing list