Hi,<br>I would like commit the attached patch (ksharedptr.h.diff).<br>It does:<br>- separate raw pointer operator from ksharedptr operators.<br>- add a clear method to make the pointer null.<br>- make the method attach only usable on raw pointer.
<br> (since it's a *low level* method and that the operator = handle all the cases)<br> I still wonder if I should make that method a private/protected one.<br><br>Other than that I would like to know the opinion of people if I make the main constructor an explicit one.
<br>Like that we could at least see while coding bugs like:<br><br>void foo(KSharedPtr<Bar> bar);<br><br>Bar *foofoo()<br>{<br> Bar *bar = new Bar();<br> foo(bar);<br> return bar; // bar is now a dandling pointer
<br>}<br><br>One main disaventage of that is that we can't use the "KSharedPtr<Foo> foo = bar;" syntax.<br>We must use the "KSharedPtr<Foo> foo(bar);" syntax.<br><br>I also attached the whole kdelibs kshared explicit constructor patch for reference to show that's it's quite simple to convert to explicit constructor.
<br>It adds some not pretty code at some place, but it's a private diff and I don't intend to commit it like this.<br><br>Michel<br>