|
1 | 1 | --- |
2 | 2 | description: "Learn more about: <ranges> helper functions" |
3 | 3 | title: "<ranges> helper functions" |
4 | | -ms.date: 06/10/2022 |
| 4 | +ms.date: 06/16/2022 |
5 | 5 | 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"] |
6 | 6 | 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"] |
7 | 7 | dev_langs: ["C++"] |
@@ -63,6 +63,8 @@ If `auto(rg.begin())` yields an iterator, returns the equivalent of `auto(rg.beg |
63 | 63 | ### `begin` example |
64 | 64 |
|
65 | 65 | ```cpp |
| 66 | +// requires /std:c++20 or later |
| 67 | +#include <vector> |
66 | 68 | #include <ranges> |
67 | 69 | #include <iostream> |
68 | 70 |
|
@@ -108,6 +110,8 @@ If `auto(rg.cbegin())` yields an iterator, returns the equivalent of `auto(rg.cb |
108 | 110 | ### `cbegin` example |
109 | 111 |
|
110 | 112 | ```cpp |
| 113 | +// requires /std:c++20 or later |
| 114 | +#include <vector> |
111 | 115 | #include <ranges> |
112 | 116 | #include <iostream> |
113 | 117 |
|
@@ -151,6 +155,8 @@ The sentinel that follows the last element in the `const`-qualified range: |
151 | 155 | ### `cend` example |
152 | 156 |
|
153 | 157 | ```cpp |
| 158 | +// requires /std:c++20 or later |
| 159 | +#include <vector> |
154 | 160 | #include <ranges> |
155 | 161 | #include <iostream> |
156 | 162 |
|
@@ -199,6 +205,8 @@ If `auto(rg.crbegin())` yields an iterator, returns the equivalent of `auto(rg.c |
199 | 205 | ### `crbegin` example |
200 | 206 |
|
201 | 207 | ```cpp |
| 208 | +// requires /std:c++20 or later |
| 209 | +#include <vector> |
202 | 210 | #include <ranges> |
203 | 211 | #include <iostream> |
204 | 212 |
|
@@ -243,6 +251,8 @@ The sentinel at the end of what `cbegin()` returns. The sentinel follows the las |
243 | 251 | ### `crend`example |
244 | 252 |
|
245 | 253 | ```cpp |
| 254 | +// requires /std:c++20 or later |
| 255 | +#include <vector> |
246 | 256 | #include <ranges> |
247 | 257 | #include <iostream> |
248 | 258 |
|
@@ -281,6 +291,8 @@ A pointer, based on the type of the range, to the first element in the contiguou |
281 | 291 | ### Example |
282 | 292 |
|
283 | 293 | ```cpp |
| 294 | +// requires /std:c++20 or later |
| 295 | +#include <vector> |
284 | 296 | #include <ranges> |
285 | 297 | #include <iostream> |
286 | 298 |
|
@@ -322,6 +334,8 @@ A `const` pointer, based on the type of the range, to the first element data in |
322 | 334 | ### `cdata` Example |
323 | 335 |
|
324 | 336 | ```cpp |
| 337 | +// requires /std:c++20 or later |
| 338 | +#include <vector> |
325 | 339 | #include <ranges> |
326 | 340 | #include <iostream> |
327 | 341 |
|
@@ -369,6 +383,8 @@ The sentinel that follows the last element in the range: |
369 | 383 | ### Example |
370 | 384 |
|
371 | 385 | ```cpp |
| 386 | +// requires /std:c++20 or later |
| 387 | +#include <vector> |
372 | 388 | #include <ranges> |
373 | 389 | #include <iostream> |
374 | 390 |
|
@@ -405,12 +421,14 @@ Returns `true` if the range has no elements; otherwise `false.` |
405 | 421 | ### Example |
406 | 422 |
|
407 | 423 | ```cpp |
| 424 | +// requires /std:c++20 or later |
| 425 | +#include <vector> |
408 | 426 | #include <ranges> |
409 | 427 | #include <iostream> |
410 | 428 |
|
411 | 429 | int main() |
412 | 430 | { |
413 | | - std::vector v{ 10,20,30 }; |
| 431 | + std::vector v{10,20,30}; |
414 | 432 | std::vector<int> v2; |
415 | 433 |
|
416 | 434 | 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 |
453 | 471 | ### Example |
454 | 472 |
|
455 | 473 | ```cpp |
| 474 | +// requires /std:c++20 or later |
| 475 | +#include <vector> |
456 | 476 | #include <ranges> |
457 | 477 | #include <iostream> |
458 | 478 |
|
@@ -497,6 +517,8 @@ A reverse iterator to the sentinel at the end of the range. The sentinel follows |
497 | 517 | ### Example |
498 | 518 |
|
499 | 519 | ```cpp |
| 520 | +// requires /std:c++20 or later |
| 521 | +#include <vector> |
500 | 522 | #include <ranges> |
501 | 523 | #include <iostream> |
502 | 524 |
|
@@ -538,6 +560,8 @@ This function executes in constant time. |
538 | 560 | ### Example |
539 | 561 |
|
540 | 562 | ```cpp |
| 563 | +// requires /std:c++20 or later |
| 564 | +#include <vector> |
541 | 565 | #include <ranges> |
542 | 566 | #include <iostream> |
543 | 567 |
|
@@ -577,6 +601,8 @@ This function executes in constant time. |
577 | 601 | ### Example |
578 | 602 |
|
579 | 603 | ```cpp |
| 604 | +// requires /std:c++20 or later |
| 605 | +#include <vector> |
580 | 606 | #include <ranges> |
581 | 607 | #include <iostream> |
582 | 608 |
|
|
0 commit comments