Std :: vector debug and release builds using g ++

Possible duplicate:
Check GCC STL binding

Is there something like an automatic debug version of std: vector in g ++ STL, and if not, how could I achieve it?

I want to specify the debug parameter in my g ++ call, for example:

g++ -D DEBUG_ main.cpp

When this parameter is defined, I want all my std :: vectors to check their borders when entering an element, the way I use vector :: at ().

When the parameter is omitted, I want all the vectors to behave as if the normal [] operator was used, which means that the performance was not "wasted" to check the boundaries.

I heard that VC ++ is doing something like this. So my question is how to do this with g ++?

+3
2

, at() [] .

at() - out_of_bounds, [] -

0

All Articles