[libstdc++ PATCH] libstdc++ debug mode
Doug Gregor
dgregor@apple.com
Thu Jul 17 16:21:00 GMT 2003
On Thursday, July 17, 2003, at 2:38AM, Gawain Bolton wrote:
> I think the debug mode patch you are proposing for libstdc++ is great.
> I
> would even say it is essential given the number of misuses of the C++
> standard library I have seen! I especially like how iterators are
> automatically invalidated when performing operations which invalidate
> them.
Glad I was able to get you interested :)
> I have a few questions though:
> 1. Why do you provide trivial destructors? (For example: "~deque()
> { }").
Two reasons:
1) Habit :)
2) To generate the debug wrappers, I actually copied verbatim the
synopsis sections of the standard and amended them according to DRs, so
if the synopsis listed the destructor, I put in the {} instead of
removing it. Interface accuracy is _very_ important to me.
> 2. Can a program (executable) be compiled with some parts using the
> debug version of libsdtc++ and others the nominal verson?
In the patch I supplied, no. I'm testing a different patch that allows
mixing debug and non-debug (but gives up some of the checking behavior,
unfortunately).
> 2.1 Along the same lines, but pushing things further, how
> could one
> have debug mode turned on for a specific container type (eg.
> std::list) or
> variable (e.g. just for variable "foo" of type std::map in bar()?
There isn't currently a way to turn on debug mode for a specific
container template (e.g., std::list), but the debug wrappers are
available in a separate namespace __gnu_cxx::debug. So if you want your
"foo" to be a debugging std::map<...>, include <ext/debug/map> and
change its type to __gnu_cxx::debug::map<...>. Depending on how your
program references the name std::map, you might be able to pull some
using declaration tricks to decide between the two :)
Note: the header location and namespace will be changing as requested
by Benjamin, so don't rely on them just yet.
Doug
More information about the Libstdc++
mailing list