std::list<T,Allocator>:: rend, std::list<T,Allocator>:: crend
From fr.cppreference.net
C++
Containers library
|
(C++17)
|
||||
| Sequence | ||||
|
(C++11)
|
||||
|
(C++26)
|
||||
|
(C++26)
|
||||
|
(C++11)
|
||||
| Associative | ||||
| Unordered associative | ||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
|
(C++11)
|
||||
| Adaptors | ||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
|
(C++23)
|
||||
| Views | ||||
|
(C++20)
|
||||
|
(C++23)
|
||||
| Tables | ||||
| Iterator invalidation | ||||
| Member function table | ||||
| Non-member function table |
std::list
| Member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Non-member functions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Deduction guides (C++17) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
reverse_iterator rend
(
)
;
|
(1) |
(noexcept depuis C++11)
(constexpr depuis C++26) |
|
const_reverse_iterator rend
(
)
const
;
|
(2) |
(noexcept depuis C++11)
(constexpr depuis C++26) |
|
const_reverse_iterator crend
(
)
const
noexcept
;
|
(3) |
(depuis C++11)
(constexpr depuis C++26) |
Retourne un itérateur inverse après le dernier élément de la version inversée * this . Il correspond à l'élément précédant le premier élément de la version non inversée * this .
Cet itérateur retourné agit uniquement comme un sentinelle. Il n'est pas garanti qu'il soit déréférençable .
SommaireValeur de retourItérateur inverse vers l'élément suivant le dernier élément. ComplexitéConstante. Notes
libc++ rétroporte
ExempleExécuter ce code #include <algorithm>
#include <cassert>
#include <iostream>
#include <numeric>
#include <string>
#include <list>
int main()
{
std::list<int> nums{1, 2, 4, 8, 16};
std::list<std::string> fruits{"orange", "apple", "raspberry"};
std::list<char> empty;
// Print list nums.
std::for_each(nums.crbegin(), nums.crend(),
[](const int n) { std::cout << n << ' '; });
std::cout << '\n';
// Sum all integers in the list nums, printing only the result.
std::cout << "Sum of nums: "
<< std::accumulate(nums.crbegin(), nums.crend(), 0) << '\n';
// Print the last fruit in the list fruits, checking if there is any.
if (!fruits.empty())
std::cout << "Last fruit: " << *fruits.crbegin() << '\n';
if (empty.crbegin() == empty.crend())
std::cout << "list ‘empty’ is indeed empty.\n";
// Modify the last element in nums.
*nums.rbegin() = 32;
assert(*nums.crbegin() == 32);
}
Sortie: 16 8 4 2 1
Sum of nums: 31
Last fruit: raspberry
list ‘empty’ is indeed empty.
Voir aussi
|