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
Copy file name to clipboardExpand all lines: docs/standard-library/checked-iterators.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,18 +12,18 @@ Checked iterators ensure that the bounds of your container are not overwritten.
12
12
13
13
## Remarks
14
14
15
-
For information about how to disable warnings that are generated by checked iterators, see [_SCL_SECURE_NO_WARNINGS](../standard-library/scl-secure-no-warnings.md).
15
+
For information about how to disable warnings that are generated by checked iterators, see [`_SCL_SECURE_NO_WARNINGS`](../standard-library/scl-secure-no-warnings.md).
16
16
17
-
You can use the [\_ITERATOR\_DEBUG\_LEVEL](../standard-library/iterator-debug-level.md) preprocessor macro to enable or disable the checked iterators feature. If _ITERATOR_DEBUG_LEVEL is defined as 1 or 2, unsafe use of iterators causes a runtime error and the program is terminated. If defined as 0, checked iterators are disabled. By default, the value for _ITERATOR_DEBUG_LEVEL is 0 for release builds and 2 for debug builds.
17
+
You can use the [`_ITERATOR_DEBUG_LEVEL`](../standard-library/iterator-debug-level.md) preprocessor macro to enable or disable the checked iterators feature. If `_ITERATOR_DEBUG_LEVEL` is defined as 1 or 2, unsafe use of iterators causes a runtime error and the program is terminated. If defined as 0, checked iterators are disabled. By default, the value for `_ITERATOR_DEBUG_LEVEL` is 0 for release builds and 2 for debug builds.
18
18
19
19
> [!IMPORTANT]
20
-
> Older documentation and source code may refer to the [_SECURE_SCL](../standard-library/secure-scl.md) macro. Use _ITERATOR_DEBUG_LEVEL to control _SECURE_SCL. For more information, see [_ITERATOR_DEBUG_LEVEL](../standard-library/iterator-debug-level.md).
20
+
> Older documentation and source code may refer to the [`_SECURE_SCL`](../standard-library/secure-scl.md) macro. Use `_ITERATOR_DEBUG_LEVEL` to control `_SECURE_SCL`. For more information, see [`_ITERATOR_DEBUG_LEVEL`](../standard-library/iterator-debug-level.md).
21
21
22
-
When _ITERATOR_DEBUG_LEVEL is defined as 1 or 2, these iterator checks are performed:
22
+
When `_ITERATOR_DEBUG_LEVEL` is defined as 1 or 2, these iterator checks are performed:
23
23
24
-
- All standard iterators (for example, [vector::iterator](../standard-library/vector-class.md#iterator)) are checked.
24
+
- All standard iterators (for example, [`vector::iterator`](../standard-library/vector-class.md#iterator)) are checked.
25
25
26
-
- If an output iterator is a checked iterator, calls to standard library functions such as [std::copy](../standard-library/algorithm-functions.md#copy) get checked behavior.
26
+
- If an output iterator is a checked iterator, calls to standard library functions such as [`std::copy`](../standard-library/algorithm-functions.md#copy) get checked behavior.
27
27
28
28
- If an output iterator is an unchecked iterator, calls to standard library functions cause compiler warnings.
29
29
@@ -50,7 +50,7 @@ When _ITERATOR_DEBUG_LEVEL is defined as 1 or 2, these iterator checks are perfo
50
50
:::column-end:::
51
51
:::row-end:::
52
52
53
-
When _ITERATOR_DEBUG_LEVEL is defined as 0:
53
+
When `_ITERATOR_DEBUG_LEVEL` is defined as 0:
54
54
55
55
- All standard iterators are unchecked. Iterators can move beyond the container boundaries, which leads to undefined behavior.
56
56
@@ -60,11 +60,11 @@ When _ITERATOR_DEBUG_LEVEL is defined as 0:
60
60
61
61
A checked iterator refers to an iterator that calls `invalid_parameter_handler` if you attempt to move past the boundaries of the container. For more information about `invalid_parameter_handler`, see [Parameter Validation](../c-runtime-library/parameter-validation.md).
62
62
63
-
The iterator adaptors that support checked iterators are [checked_array_iterator Class](../standard-library/checked-array-iterator-class.md) and [unchecked_array_iterator Class](../standard-library/unchecked-array-iterator-class.md).
63
+
The iterator adaptors that support checked iterators are [`checked_array_iterator` Class](../standard-library/checked-array-iterator-class.md) and [`unchecked_array_iterator` Class](../standard-library/unchecked-array-iterator-class.md).
64
64
65
65
## Examples
66
66
67
-
When you compile by using _ITERATOR_DEBUG_LEVEL set to 1 or 2, a runtime error will occur if you attempt to access an element that is outside the bounds of the container by using the indexing operator of certain classes.
67
+
When you compile by using `_ITERATOR_DEBUG_LEVEL` set to 1 or 2, a runtime error will occur if you attempt to access an element that is outside the bounds of the container by using the indexing operator of certain classes.
68
68
69
69
```cpp
70
70
// checked_iterators_1.cpp
@@ -91,7 +91,7 @@ int main()
91
91
92
92
This program prints "67" then pops up an assertion failure dialog box with additional information about the failure.
93
93
94
-
Similarly, when you compile by using _ITERATOR_DEBUG_LEVEL set to 1 or 2, a runtime error will occur if you attempt to access an element by using `front` or `back` in container classes when the container is empty.
94
+
Similarly, when you compile by using `_ITERATOR_DEBUG_LEVEL` set to 1 or 2, a runtime error will occur if you attempt to access an element by using `front` or `back` in container classes when the container is empty.
95
95
96
96
```cpp
97
97
// checked_iterators_2.cpp
@@ -113,7 +113,7 @@ int main()
113
113
114
114
This program pops up an assertion failure dialog box with additional information about the failure.
115
115
116
-
The following code demonstrates various iterator use-case scenarios with comments about each. By default, _ITERATOR_DEBUG_LEVEL is set to 2 in Debug builds, and to 0 in Retail builds.
116
+
The following code demonstrates various iterator use-case scenarios with comments about each. By default, `_ITERATOR_DEBUG_LEVEL` is set to 2 in Debug builds, and to 0 in Retail builds.
0 commit comments