wrote:
>the small ones are all right, but I was rather thinking of a little >framework which I built upon macros and templates and which basically >emulated Delphi's "safecall" convention (i.e. COM exception >firewalling) in C++.
you mean something similar to IErrorInfo support implemented in ATL headers?
>they're strictly typed at declaration time. I assume your >MakeBeginEndUpdate() is a function template that generates calls to >obj->BeginUpdate() and obj->EndUpdate() regardless of what type obj has >(some kind of static duck typing). You can't do that with generics;
template <class Obj> class BeginEndUpdate : public ScopeGuardImplBase { public: static BeginEndUpdate<Obj> MakeGuard(Obj& obj) { return BeginEndUpdate<Obj>(obj); } ~BeginEndUpdate() throw() { SafeExecute(*this); } void EndUpdate() { if(!dismissed_) { obj_.EndUpdate(); dismissed_=true; } } void Execute() const { EndUpdate(); } protected: BeginEndUpdate(Obj& obj) : obj_(obj) { obj_.BeginUpdate();
V_ASSERT(!dismissed_); } Obj& obj_; };
template <class Obj> inline BeginEndUpdate<Obj> MakeBeginEndUpdate(Obj & obj) { return BeginEndUpdate<Obj>::MakeGuard(obj); }
> LVSG.Create (procedure begin ListView1.BeginUpdate end, > procedure begin ListView1.EndUpdate end);
I'm yet to learn all those newer delphi concepts. doesn't look very appealing though :) I guess I'll stick with my evil macros for bcb projects while trying to grasp new methods instead of try/finally for new delphi projects
-- Vladimir Ulchenko aka vavan