Skip to content

Commit def8ce2

Browse files
authored
Merge pull request MicrosoftDocs#4357 from TylerMSFT/updateexamples
fix examples
2 parents b492610 + 2ebbfce commit def8ce2

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

‎docs/standard-library/range-functions.md‎

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: <ranges> helper functions"
33
title: "<ranges> helper functions"
4-
ms.date: 06/10/2022
4+
ms.date: 06/16/2022
55
f1_keywords: ["ranges/std::ranges::begin", "ranges/std::ranges::end", "ranges/std::ranges::cbegin", "ranges/std::ranges::cend", "ranges/std::ranges::rbegin", "ranges/std::ranges::rend", "ranges/std::ranges::crbegin", "ranges/std::ranges::crend", "ranges/std::ranges::size","ranges/std::ranges::ssize","ranges/std::ranges::empty","ranges/std::ranges::data","ranges/std::ranges::cdata"]
66
helpviewer_keywords: ["std::ranges [C++], ranges::begin", "std::ranges [C++], ranges::end", "std::ranges [C++], ranges::cbegin", "std::ranges [C++], ranges::cend", "std::ranges [C++], ranges::rbegin", "std::ranges [C++], ranges::rend", "std::ranges [C++], ranges::crbegin", "std::ranges [C++], ranges::crend", "std::ranges [C++], ranges::size","std::ranges [C++], ranges::ssize","std::ranges [C++], ranges::empty","std::ranges [C++], ranges::data","std::ranges [C++], ranges::cdata"]
77
dev_langs: ["C++"]
@@ -63,6 +63,8 @@ If `auto(rg.begin())` yields an iterator, returns the equivalent of `auto(rg.beg
6363
### `begin` example
6464
6565
```cpp
66+
// requires /std:c++20 or later
67+
#include <vector>
6668
#include <ranges>
6769
#include <iostream>
6870
@@ -108,6 +110,8 @@ If `auto(rg.cbegin())` yields an iterator, returns the equivalent of `auto(rg.cb
108110
### `cbegin` example
109111
110112
```cpp
113+
// requires /std:c++20 or later
114+
#include <vector>
111115
#include <ranges>
112116
#include <iostream>
113117
@@ -151,6 +155,8 @@ The sentinel that follows the last element in the `const`-qualified range:
151155
### `cend` example
152156
153157
```cpp
158+
// requires /std:c++20 or later
159+
#include <vector>
154160
#include <ranges>
155161
#include <iostream>
156162
@@ -199,6 +205,8 @@ If `auto(rg.crbegin())` yields an iterator, returns the equivalent of `auto(rg.c
199205
### `crbegin` example
200206
201207
```cpp
208+
// requires /std:c++20 or later
209+
#include <vector>
202210
#include <ranges>
203211
#include <iostream>
204212
@@ -243,6 +251,8 @@ The sentinel at the end of what `cbegin()` returns. The sentinel follows the las
243251
### `crend`example
244252
245253
```cpp
254+
// requires /std:c++20 or later
255+
#include <vector>
246256
#include <ranges>
247257
#include <iostream>
248258
@@ -281,6 +291,8 @@ A pointer, based on the type of the range, to the first element in the contiguou
281291
### Example
282292
283293
```cpp
294+
// requires /std:c++20 or later
295+
#include <vector>
284296
#include <ranges>
285297
#include <iostream>
286298
@@ -322,6 +334,8 @@ A `const` pointer, based on the type of the range, to the first element data in
322334
### `cdata` Example
323335
324336
```cpp
337+
// requires /std:c++20 or later
338+
#include <vector>
325339
#include <ranges>
326340
#include <iostream>
327341
@@ -369,6 +383,8 @@ The sentinel that follows the last element in the range:
369383
### Example
370384
371385
```cpp
386+
// requires /std:c++20 or later
387+
#include <vector>
372388
#include <ranges>
373389
#include <iostream>
374390
@@ -405,12 +421,14 @@ Returns `true` if the range has no elements; otherwise `false.`
405421
### Example
406422
407423
```cpp
424+
// requires /std:c++20 or later
425+
#include <vector>
408426
#include <ranges>
409427
#include <iostream>
410428
411429
int main()
412430
{
413-
std::vector v{ 10,20,30 };
431+
std::vector v{10,20,30};
414432
std::vector<int> v2;
415433
416434
std::cout << std::boolalpha << std::ranges::empty(v); // outputs: false
@@ -453,6 +471,8 @@ If `auto(rg.rbegin())` yields an iterator, returns the equivalent of `auto(rg.rb
453471
### Example
454472
455473
```cpp
474+
// requires /std:c++20 or later
475+
#include <vector>
456476
#include <ranges>
457477
#include <iostream>
458478
@@ -497,6 +517,8 @@ A reverse iterator to the sentinel at the end of the range. The sentinel follows
497517
### Example
498518
499519
```cpp
520+
// requires /std:c++20 or later
521+
#include <vector>
500522
#include <ranges>
501523
#include <iostream>
502524
@@ -538,6 +560,8 @@ This function executes in constant time.
538560
### Example
539561

540562
```cpp
563+
// requires /std:c++20 or later
564+
#include <vector>
541565
#include <ranges>
542566
#include <iostream>
543567

@@ -577,6 +601,8 @@ This function executes in constant time.
577601
### Example
578602

579603
```cpp
604+
// requires /std:c++20 or later
605+
#include <vector>
580606
#include <ranges>
581607
#include <iostream>
582608

0 commit comments

Comments
 (0)