Skip to content

Commit 5ece97e

Browse files
author
Dmitry Banschikov
committed
Fix span C-style traversal example
1 parent 111dcfa commit 5ece97e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

CppCoreGuidelines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2664,7 +2664,7 @@ A `span` represents a range of elements, but how do we manipulate elements of th
26642664
void f(span<int> s)
26652665
{
26662666
for (int x : s) cout << x << '\n'; // range traversal (guaranteed correct)
2667-
for (int i = 0; i < s.size(); ++i) cout << x << '\n'; // C-style traversal (potentially checked)
2667+
for (int i = 0; i < s.size(); ++i) cout << s[i] << '\n'; // C-style traversal (potentially checked)
26682668
s[7] = 9; // random access (potentially checked)
26692669
std::sort(&s[0], &s[s.size() / 2]); // extract pointers (potentially checked)
26702670
}

0 commit comments

Comments
 (0)