Boost logo

Boost :

From: Rob Stewart (stewart_at_[hidden])
Date: 2005-07-26 21:39:53


> Date: Tue, 26 Jul 2005 13:10:17 -0400
> From: Jason Hise <chaos_at_[hidden]>
> Reply-To: boost_at_[hidden]
> Sender: boost-bounces_at_[hidden]
>
> I am trying to come up with a mechanism which allows member functions of
> the singleton to be called if the instance exists, and which do nothing
> if the instance does not exist (no creation is attempted, the operation
> is simply skipped). My current idea is a member function of the
> singleton pointer named zombie_call, which would be used something like:
>
> ptr.zombie_call ( &MySingletonType::SomeFunc, param1, param2, ... );
>
> The only problem I have is what to do if the instance does not exist and
> the member function has a return value. Should I just return a
> default-constructed object in these cases? (And what should happen if
> the return type does not have a constructor taking no arguments?)
> Should I append a parameter to the end of zombie_call which is returned
> if the instance does not exist, and have it default to a
> default-constructed object? Should I append a parameter that is a
> reference to the return type, and just assign the return value to it if
> the operation is successful? (And what happens if the return type is
> already a reference?) Should I just enforce that member functions
> called with zombie_call return void?
>
> Also, is there any way to make the syntax of the call a bit nicer? I
> was originally hoping to have a separate pointer type called zombie_ptr,
> which just behaved in this manner when functions were accessed via
> operator->, but I couldn't think of a non-intrusive way to pull it off...
>
> Any and all thoughts are appreciated.
>
> -Jason
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>

-- 
Rob Stewart                           stewart_at_[hidden]
Software Engineer                     http://www.sig.com
Susquehanna International Group, LLP  using std::disclaimer;

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk