Skip to content

Repo sync for protected CLA branch #4098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions docs/standard-library/debug-iterator-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ description: "Learn more about: Debug Iterator Support"
title: "Debug Iterator Support"
ms.date: "09/13/2018"
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"]
ms.assetid: f3f5bd15-4be8-4d64-a4d0-8bc0761c68b6
---
# Debug Iterator Support

Expand Down Expand Up @@ -43,7 +42,7 @@ int main() {

## Using _ITERATOR_DEBUG_LEVEL

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.
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.

```cpp
// iterator_debugging_1.cpp
Expand Down Expand Up @@ -74,9 +73,9 @@ int main() {
-572662307
```

## Unitialized iterators
## Uninitialized iterators

An assert also occurs if you attempt to use an iterator before it is initialized, as shown here:
An assert also occurs if you attempt to use an iterator before it's initialized, as shown here:

```cpp
// iterator_debugging_2.cpp
Expand Down Expand Up @@ -113,7 +112,7 @@ int main()
}
```

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).
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).

## Iterators going out of scope

Expand All @@ -135,7 +134,7 @@ int main() {

## Destructors for debug iterators

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:
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:

```cpp
// iterator_debugging_5.cpp
Expand Down