Difference between revisions of "cpp/container/list/back"
From cppreference.com
m (Add link to edit the included template) |
m (r2.7.3) (Robot: Adding fr:cpp/container/list/back, it:cpp/container/list/back, zh:cpp/container/list/back) |
||
Line 3: | Line 3: | ||
[[de:cpp/container/list/back]] | [[de:cpp/container/list/back]] | ||
[[es:cpp/container/list/back]] | [[es:cpp/container/list/back]] | ||
+ | [[fr:cpp/container/list/back]] | ||
+ | [[it:cpp/container/list/back]] | ||
[[ja:cpp/container/list/back]] | [[ja:cpp/container/list/back]] | ||
[[pt:cpp/container/list/back]] | [[pt:cpp/container/list/back]] | ||
[[ru:cpp/container/list/back]] | [[ru:cpp/container/list/back]] | ||
+ | [[zh:cpp/container/list/back]] |
Revision as of 19:43, 2 November 2012
reference back(); |
(1) | |
const_reference back() const; |
(2) | |
Returns a reference to the last element in the container.
Calling back
on an empty container causes undefined behavior.
Contents |
Parameters
(none)
Return value
Reference to the last element.
Complexity
Constant.
Notes
For a non-empty container c
, the expression c.back() is equivalent to *std::prev(c.end()).
Example
Run this code
See also
access the first element (public member function) | |
(C++11) |
returns a reverse iterator to the beginning (public member function) |
(C++11) |
returns an iterator to the end (public member function) |