March 12, 2007
Mathew,



Since I'm the only one interested here it goes:

My suggestion goes for a different name (for example: scoped_function :-) ).
The name suggestion is just because then I would like something that acts
like scope_handle<void> but also support's the this calling convention.
Getting the this pointer into the RAII class as well as supporting a other
type of functions is something I would consider you a better person to solve
and I. :-)
The problem here is that there would be an overlap of functionality,
although in the case of this new functionality appeared in stlsoft then I
would only use scope_handle when there is some sort of recourse that I want
to manage.

I only suggest a more general approach, because I would prefer then just one way of calling a function upon a closure of scope. I would think that the Thief constructor would also be helpful; at least I'm using it.



Kind Regards

Cláudio Albuquerque








"Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:essph4$sji$1@digitalmars.com...
> Ah, the problem there is that it's not designed to do that for member functions.
>
> I wouldn't want to alter scoped_handle to do that, but I would be open to implementing an RAII class template - e.g. scoped_method - to do that.
>
> Anyone got any ideas on this one, to give me a kick start?
>
>
> "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:esraio$12d3$2@digitalmars.com...
>>
>> Hi Mathew,
>>
>> I'm trying to use the implementation that you recomended
>> [scoped_handle<void> OpInitializeFinalize(FinalizeFunc);], but with
>> member
>> functions and I got a couple of errors. Could you help is it possible for
>> you to help me on this? [I am using beta-44.]
>>
>> Thanks In Advance
>> Cláudio Albuquerque
>>
>> stlsoft::scoped_handle<void> scopedEndOperation (
>> &baseClass::EndOperation );
>>
>> Error 4 error C2664: 'stlsoft::scoped_handle<void>::scoped_handle(void
>> (__cdecl *)(void))' : cannot convert parameter 1 from 'bool (__thiscall
>> teste::* )(void)' to 'void (__cdecl *)(void)'
>>
>> scoped_handle<void> scopedFinalize( baseClass::OpFinalize() );
>>
>> Error 5 error C2664: 'stlsoft::scoped_handle<void>::scoped_handle(void
>> (__cdecl *)(void))' : cannot convert parameter 1 from 'bool' to 'void
>> (__cdecl *)(void)'
>>
>>
>>
>> "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqdfu3$10ap$1@digitaldaemon.com...
>> >
>> > "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqdc5a$r9r$1@digitaldaemon.com...
>> >>
>> >> Humm I see
>> >>
>> >> Ok, although I would like the "other" syntax better, I can see also
> some
>> >> advantages to this.
>> >>
>> >> Thanks Mathew!
>> >
>> > You're welcome. ;-)
>> >
>> >>
>> >>
>> >> "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqd9t0$nv0$1@digitaldaemon.com...
>> >> >
>> >> > I mean:
>> >> >
>> >> > void MyFunc()
>> >> > {
>> >> >    ...
>> >> >    InitializeFunc();
>> >> >    scoped_handle<void> OpInitializeFinalize(FinalizeFunc);
>> >> >    ...
>> >> > }
>> >> >
>> >> >
>> >>
>> >>
>> >
>> >
>>
>>
>>
>
> 


1 2
Next ›   Last »