- 论坛徽章:
- 0
|
早上无聊,用CDT玩一下调试,代码如下- #include <iostream>
- #include <vector>
- using namespace std;
- int main() {
- vector<int> vint;
- vint.push_back(1);
- cout << vint[0] << endl;
- cout << vint[1] << endl;
- return 0;
- }
复制代码 不出错的...,一看实现和ms的stl不一样
linux stl- reference operator[](size_type __n)
- { return *(this->_M_impl._M_start + __n); }
复制代码 ms stl- reference operator[](size_type _Pos)
- { // subscript mutable sequence
- #if _ITERATOR_DEBUG_LEVEL == 2
- if (size() <= _Pos)
- { // report error
- _DEBUG_ERROR("vector subscript out of range");
- _SCL_SECURE_OUT_OF_RANGE;
- }
- #elif _ITERATOR_DEBUG_LEVEL == 1
- _SCL_SECURE_VALIDATE_RANGE(_Pos < size());
- #endif /* _ITERATOR_DEBUG_LEVEL */
- return (*(this->_Myfirst + _Pos));
- }
复制代码 还有随便问一下,CDT怎么显示map的元素
map<int, int> mint;
mint[0] = 1;
在调试查看窗口中,无法显示mint[0]的值 |
|