| Thread overview | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
February 07, 2007 scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Hi Mathew, I've been browsing the STLSoft documentation looking for something like scoped_handle but that applies the same principle but to two functions. Unfortunately did not find it, and instead of rushing into the implementation, a chosen a wiser path and decided that asking you would hurt. So STLSoft already has something like applying the RAII idea but to functions? Thanks Cláudio Albuquerque | ||||
February 07, 2007 Re: scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Cláudio Albuquerque | Not sure what you mean. Can you give me an illustration of what you mean? Matthew "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqc6nd$2815$1@digitaldaemon.com... > Hi Mathew, > > > > I've been browsing the STLSoft documentation looking for something like scoped_handle but that applies the same principle but to two functions. Unfortunately did not find it, and instead of rushing into the implementation, a chosen a wiser path and decided that asking you would hurt. So STLSoft already has something like applying the RAII idea but to functions? > > > > Thanks > > Cláudio Albuquerque > > | |||
February 07, 2007 Re: scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson |
Sure,
void MyFunc()
{
...
scoped_functions<InitializeFunc,FinalizeFunc> OpInitializeFinalize;
...
}
When I declare the scoped_functions object, it will call the InitializeFunc() function, when the object goes out of scope it will call the FinalizeFun().
Hope this explanation helps.
Regards
Cláudio Albuquerque
"Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqcc8u$2fni$1@digitaldaemon.com...
> Not sure what you mean. Can you give me an illustration of what you mean?
>
> Matthew
>
>
> "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqc6nd$2815$1@digitaldaemon.com...
>> Hi Mathew,
>>
>>
>>
>> I've been browsing the STLSoft documentation looking for something like scoped_handle but that applies the same principle but to two functions. Unfortunately did not find it, and instead of rushing into the implementation, a chosen a wiser path and decided that asking you would hurt. So STLSoft already has something like applying the RAII idea but to functions?
>>
>>
>>
>> Thanks
>>
>> Cláudio Albuquerque
>>
>>
>
>
| |||
February 07, 2007 Re: scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Cláudio Albuquerque | I see.
No, scoped_handle does not support that syntax. However, it does support that functionality, as in:
void MyFunc()
{
...
InitializeFunc();
scoped_functions<void> OpInitializeFinalize(FinalizeFunc);
...
}
:-)
Cheers
Matthew
"Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqd624$in5$1@digitaldaemon.com...
>
> Sure,
>
> void MyFunc()
> {
> ...
> scoped_functions<InitializeFunc,FinalizeFunc> OpInitializeFinalize;
> ...
> }
>
> When I declare the scoped_functions object, it will call the
> InitializeFunc() function, when the object goes out of scope it will call
> the FinalizeFun().
>
> Hope this explanation helps.
>
> Regards
> Cláudio Albuquerque
>
>
> "Matthew Wilson" <matthew@hat.stlsoft.dot.org> wrote in message news:eqcc8u$2fni$1@digitaldaemon.com...
> > Not sure what you mean. Can you give me an illustration of what you
mean?
> >
> > Matthew
> >
> >
> > "Cláudio Albuquerque" <0318222801@netcabo.pt> wrote in message news:eqc6nd$2815$1@digitaldaemon.com...
> >> Hi Mathew,
> >>
> >>
> >>
> >> I've been browsing the STLSoft documentation looking for something like scoped_handle but that applies the same principle but to two functions. Unfortunately did not find it, and instead of rushing into the implementation, a chosen a wiser path and decided that asking you would hurt. So STLSoft already has something like applying the RAII idea but
to
> >> functions?
> >>
> >>
> >>
> >> Thanks
> >>
> >> Cláudio Albuquerque
> >>
> >>
> >
> >
>
>
| |||
February 07, 2007 Re: scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson |
I mean:
void MyFunc()
{
...
InitializeFunc();
scoped_handle<void> OpInitializeFinalize(FinalizeFunc);
...
}
| |||
February 07, 2007 Re: scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | Humm I see Ok, although I would like the "other" syntax better, I can see also some advantages to this. Thanks Mathew! "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); > ... > } > > | |||
February 07, 2007 Re: scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Cláudio Albuquerque | "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); > > ... > > } > > > > > > | |||
March 09, 2007 Re: scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | 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); >> > ... >> > } >> > >> > >> >> > > | |||
March 09, 2007 Re: scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Matthew Wilson | 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); >> > ... >> > } >> > >> > >> >> > > | |||
March 09, 2007 Re: scoped_handle but for functions? | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Cláudio Albuquerque | 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); > >> > ... > >> > } > >> > > >> > > >> > >> > > > > > > > | |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply