Boost logo

Boost :

From: Andrei Alexandrescu (andrewalex_at_[hidden])
Date: 2003-08-05 13:38:04

"John Torjo" <john.lists_at_[hidden]> wrote in message
> Indeed, but what about a wrapper for each time of handle, with a
> operator()?
> I have used it a couple of times.
> Something like:
> struct hbitmap_wrapper {
> hbitmap_wrapper( HBITMAP h);
> operator HBITMAP() { ... }
> ...
> };
> Then in code, instead of HBITMAP, use hbitmap_wrappers.

This approach is definitely sound, except that you need to write quite some
scaffolding (ctors etc. etc.) for each handle wrapped. With a policy you can
put the scaffolding in one place and then write only the stuff that varies.
In the particular case of handles, maybe there's not a ton to wrap there,
but if you want to be generic as the original poster suggested, you do need
to use parameterized types.

Ah, one more point that was discussed... there was much around operator->
and operator* which don't make sense for certain resources. With Loki's
SmartPtr, you can disable these two functions. Granted, the error message
would be different, such as "get_reference not found" as opposed to
"operator* not found". Would this be a major issue?


Boost list run by bdawes at, gregod at, cpdaniel at, john at