From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2006-07-10 05:00:41
On 7/9/06, Daryle Walker <darylew_at_[hidden]> wrote:
> > exception_info & info (get_exception_info(e));
> > info ++; // won't work, unless operator++ is defined for exception_info
> As another poster said, you can take the address of "info" and then repeat
> the same stupid pointer tricks. The programmer's advice, "guard against
> Murphy, not Machiavelli," applies here. Your pointer flaw isn't because of
> this library's API, it's a general problem in C++. That's because all
> pointers define the ++ and -- operators for use with array segments,
> ignoring the fact that a pointer can be indistinctively used for single
> objects. In other words: "if you see this code, fire the programmer".
That's why I would like to use references -- because if the user of
the library _still_ got the address, then he _had_ to get the address
and put it in a pointer to do something potentially stupid with it.
That's just preventing the regular user from making a mistake by
side-stepping pointers in the API itself.
And I agree -- if the programmer _still_ did the stupid
&get_exception_info() and did a ++ on the pointer, then maybe that
programmer should get fired. ;)
-- Dean Michael C. Berris C/C++ Software Architect Orange and Bronze Software Labs http://3w-agility.blogspot.com/ http://cplusplus-soup.blogspot.com/ Mobile: +639287291459 Email: dean [at] orangeandbronze [dot] com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk