GCC STL bound checking

夙愿已清 提交于 2019-11-26 14:33:27
Peter G.

You can activate runtime iterator and bounds checking by compiling with -D_GLIBCXX_DEBUG. Also note that random-access containers provide the always bounds-checking at()-operation in addition to operator [].

References:

GCC STL debug mode: http://gcc.gnu.org/onlinedocs/libstdc++/manual/debug_mode_using.html#debug_mode.using.mode

at() operation: std::vector::at(), std::deque::at() and std::array::at()

you should overload the operator[] for your specific classes. If you want to use an existing STL container, the at() function is a bounds-checked version of the operator[].

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!