He he. I'm failing to communicate by trying to be
terse. (Time is tres short this week.)
Basically, under my projected change, if you use a
non-nulling release fn, you can call like this:
scoped_handle<void*>
sh(::malloc(10), ::free);
or this:
void *pv = ::malloc(10);
scoped_handle<void*> sh(pv,
::free);
If you're using a nulling release func, then you
must call it like this:
void free_set_null(void **);
void *pv = ::malloc(10);
scoped_handle<void*> sh(&pv,
free_set_null);
Note that you will pass &pv, not pv, in the second case. In other
words, you pass a pointer to your variable. That way, all issues of
const/non-const / temp/non-temp just disappears. The "cost" is just that we will
remove the (recently added) ability to write:
scoped_handle<void*> sh(::malloc(10),
free_set_null);
I'm of the opinion that that cost is worth paying.
Thoughts?
As for my mood, well, I'm nearing the point where
the final draft of XSTLv1 will be dispatched to the publishers - just tidying
up, and waiting for cover quotes from reviewers ... - my boys (Bob luv 'em) are
both back at school - so I can concentrate a bit better - and I have had
very fruitful discussions with my editor about getting XSTLv2 trimmed
down and therefore likely to be written in half the time I
expected.
:-)
You're right. I'd already
considered this, and so decided that the "nulling" ctor overload would take
an address of the handle. This has the big advantage that there can be no
such confusion, and the small disadvantage that you can't "inline" the
allocation function invocation with the scoped_handle ctor.
;-)
Actually, I'm not sure I understand what you
mean.
The problem I mentioned was specifically related to and assumed
taking a reference.
Do you mean something like taking a reference as
opposed to taking a const reference to not compile (or select another ctor)
when a temp is given?
This should all work ticketyboo
(LOL, don't you love the silly English and our daft expressions!). Just give
me a few days to get over the last book push.
BigBoy
You're in a good mood
:-).
Adi