December 03, 2006 [COMSTL, Adi's report] defaulting to ownership in interface pointer wrappers | ||||
---|---|---|---|---|
| ||||
> 7. Consider making the second argument of interface_ptr<> default to false. It seems to me that this would be in the spirit of RAII too. This would be the case when directly moving the newly received pointer (say from into the interface_ptr<>, without keeping an extra "bare" copy. (This is also related to 5 above).
*Never* going to happen, I'm afraid. This is another fatal mistake of reference counting wrappers that some other libraries have made. It is always going to bite you somewhere.
Something that I've toyed with for a long time, and may yet do, is to change the bAddRef parameter from a bool to an enumeration. There's no doubt that
ISomething *psomething
stlsoft::ref_ptr<ISomething> something(psomething,
STLSOFT_CONSUME_REF); // Eat the reference
is clearer and less maintenance-fragile than:
ISomething *psomething
stlsoft::ref_ptr<ISomething> something(psomething, false); // Consume
the reference
Both are, of course, lightyears ahead of
ISomething *psomething
stlsoft::ref_ptr<ISomething> something(psomething); // WFT! Am I eating
or copying the reference? Help!
Cheers
Matthew
|
Copyright © 1999-2021 by the D Language Foundation