Skip to content

Commit 27dc740

Browse files
committed
Merge pull request #593 from ubique/span-c-style-traversal-example
Fix span C-style traversal example
2 parents e1d11c0 + 5ece97e commit 27dc740

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
@@ -2672,7 +2672,7 @@ A `span` represents a range of elements, but how do we manipulate elements of th
26722672
void f(span<int> s)
26732673
{
26742674
for (int x : s) cout << x << '\n'; // range traversal (guaranteed correct)
2675-
for (int i = 0; i < s.size(); ++i) cout << x << '\n'; // C-style traversal (potentially checked)
2675+
for (int i = 0; i < s.size(); ++i) cout << s[i] << '\n'; // C-style traversal (potentially checked)
26762676
s[7] = 9; // random access (potentially checked)
26772677
std::sort(&s[0], &s[s.size() / 2]); // extract pointers (potentially checked)
26782678
}

0 commit comments

Comments
 (0)