You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
helpviewer_keywords: ["Safe Libraries", "Safe Libraries, C++ Standard Library", "Safe C++ Standard Library", "C++ Standard Library, debug iterator support", "iterators, debug iterator support", "iterators, incompatible", "incompatible iterators", "debug iterator support"]
6
-
ms.assetid: f3f5bd15-4be8-4d64-a4d0-8bc0761c68b6
7
6
---
8
7
# Debug Iterator Support
9
8
@@ -43,7 +42,7 @@ int main() {
43
42
44
43
## Using _ITERATOR_DEBUG_LEVEL
45
44
46
-
You can use the preprocessor macro [_ITERATOR_DEBUG_LEVEL](../standard-library/iterator-debug-level.md) to turn off the iterator debugging feature in a debug build. This program does not assert, but still triggers undefined behavior.
45
+
You can use the preprocessor macro [_ITERATOR_DEBUG_LEVEL](../standard-library/iterator-debug-level.md) to turn off the iterator debugging feature in a debug build. This program doesn't assert, but still triggers undefined behavior.
47
46
48
47
```cpp
49
48
// iterator_debugging_1.cpp
@@ -74,9 +73,9 @@ int main() {
74
73
-572662307
75
74
```
76
75
77
-
## Unitialized iterators
76
+
## Uninitialized iterators
78
77
79
-
An assert also occurs if you attempt to use an iterator before it is initialized, as shown here:
78
+
An assert also occurs if you attempt to use an iterator before it's initialized, as shown here:
80
79
81
80
```cpp
82
81
// iterator_debugging_2.cpp
@@ -113,7 +112,7 @@ int main()
113
112
}
114
113
```
115
114
116
-
Notice that this example uses the lambda expression `[] (int& elem) { elem *= 2; }` instead of a functor. Although this choice has no bearing on the assert failure—a similar functor would cause the same failure—lambdas are a very useful way to accomplish compact function object tasks. For more information about lambda expressions, see [Lambda Expressions](../cpp/lambda-expressions-in-cpp.md).
115
+
Notice that this example uses the lambda expression `[] (int& elem) { elem *= 2; }` instead of a functor. Although this choice has no bearing on the assert failure—a similar functor would cause the same failure—lambdas are a way to write a short block of code. For more information about lambda expressions, see [Lambda expressions](../cpp/lambda-expressions-in-cpp.md).
117
116
118
117
## Iterators going out of scope
119
118
@@ -135,7 +134,7 @@ int main() {
135
134
136
135
## Destructors for debug iterators
137
136
138
-
Debug iterators have non-trivial destructors. If a destructor does not run but the object's memory is freed, access violations and data corruption might occur. Consider this example:
137
+
Debug iterators have non-trivial destructors. If a destructor doesn't run but the object's memory is freed, access violations and data corruption might occur. Consider this example:
0 commit comments