J
Jeremy J
Hello,
I recall reading an interesting article on automatic scope guard by A.
Alexandrescu on CUJ.com some time ago. I have since integrated my code
into my project and I find it to be very useful. However I have some
misgivings recently, because the code seems to have been all but
ignored. It took advantage of a C++ 'feature' which guarantees that
the object which a const reference point to will remain while the
const reference exists. This seems somewhat risky to me as I don't
think that the method for maintining such objects is prescribed, and
thus different compilers might have different ways of fullfilling this
guarantee. Basically, is the code 'safe'? I have moved my scope guard
implementation to use boost::function and boost::bind, but this
requires dynamic memory, while Alexandrescu's original implementation
did not.
It seems to me that such an ingenious method would have more exposure
if it was truly safe and efficient. Am I being paranoid? (said the
programmer who inserted scope guards every 20 lines of code ... hehe).
Jeremy Jurksztowicz
I recall reading an interesting article on automatic scope guard by A.
Alexandrescu on CUJ.com some time ago. I have since integrated my code
into my project and I find it to be very useful. However I have some
misgivings recently, because the code seems to have been all but
ignored. It took advantage of a C++ 'feature' which guarantees that
the object which a const reference point to will remain while the
const reference exists. This seems somewhat risky to me as I don't
think that the method for maintining such objects is prescribed, and
thus different compilers might have different ways of fullfilling this
guarantee. Basically, is the code 'safe'? I have moved my scope guard
implementation to use boost::function and boost::bind, but this
requires dynamic memory, while Alexandrescu's original implementation
did not.
It seems to me that such an ingenious method would have more exposure
if it was truly safe and efficient. Am I being paranoid? (said the
programmer who inserted scope guards every 20 lines of code ... hehe).
Jeremy Jurksztowicz