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

Returns a reference to the first element in the container.

# Declarations

reference front();
const_reference front() const;

# Return value

Reference to the first element.

# Notes

For a container c, the expression c.front() is equivalent to *c.begin().

# Example

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

# See also