On 03-10-2013 21:55, Matt Calabrese wrote:
On Thu, Oct 3, 2013 at 9:37 AM, Thorsten Ottosen < thorsten.ottosen@dezide.com> wrote:
shared_obj<Foo> sharedFoo = make_shared_obj( 42, "foo" );
would be good names.
The only issue with this is your type may not be allocated with new and you may want a custom deleter (you may also want to take control from a separately allocated object). These are things that shared_ptr can handle, but with a strict interface such as this, the non-null ptr cannot. That said, I personally don't care, but if the intent is to just have a non-null shared_ptr then we shouldn't be sacrificing existing functionality. It should simply be a shared_ptr with a non-null invariant and that is that.
The deleter thing can probably be handled with a consrtuctor like template< class D, class Args ... > shared_obj( D, Args args... ); For stuff not allocated via new, it can be probably be handled by another version of make_shared_obj. -Thorsten