VclPtr some improvements ?

Stephan Bergmann sbergman at
Mon Apr 16 07:45:38 UTC 2018

On 20/05/17 11:40, Michael Meeks wrote:
> 	Julien had some good ideas for simplifying VclPtr usage; here is the
> background - currently we have:
> 	VclPtr<Foo> pFoo;
> 		+ empty VclPtr pointer eg. shared_ptr<Foo> xFoo;
> 	VclPtrInstance<Foo> pFoo( pParent );
> 		+ creates a pFoo as above, and initializes it to an
> 		  instance; we can't expose 'new Foo()' publicly due
> 		  to the odd reference counting behavior. ::Create
> 		  is a little like make_shared
> 		+ sementically this is:
> 		  VclPtr<Foo> pFoo = VclPtr<Foo>::Create( pParent );
> 	* Suggestion - lets kill VclPtrInstance in a world with
> 	  'auto' its main use of saving a bit of typing is gone
> 	  ie.
> 		auto pFoo = VclPtr<Foo>::Create( pParent );

One more argument supporting that, 
"-Werror,-Wreturn-std-move (recent Clang trunk)":

"An explicit std::move would be needed in the return statements, as 
there's a conversion from VclPtrInstance to base class VclPtr involved. 
One more reason to better get rid of VclPtrInstance completely in favor 
of VclPtr::Create, as already mentioned in [this mail thread]."

More information about the LibreOffice mailing list