std::list<T,Allocator>::back

Returns a reference to the last element in the container.

# Declarations

reference back();
const_reference back() const;

# Return value

Reference to the last element.

# Notes

For a non-empty container c, the expression c.back() is equivalent to *std::prev(c.end()).

# Example

#include <cassert>
#include <list>
 
int main()
{
    std::list<char> letters{'a', 'b', 'c', 'd'};
    assert(letters.back() == 'd');
}

# See also