Namespaces
Variants
Views
Actions

Difference between revisions of "Template:cpp/container/begin"

From cppreference.com
(+)
Line 64: Line 64:
 
Constant
 
Constant
 
{{#if:{{#pos:{{{1}}}|set}}|{{cpp/container/constant iterator note}}}}
 
{{#if:{{#pos:{{{1}}}|set}}|{{cpp/container/constant iterator note}}}}
 +
 +
===Notes===
 +
Note that both iterator and const_iterator are Constant {{named req|ForwardIterator}}s, and thus none of these methods return an iterator that can be used to mutate the elements of the container.
  
 
===Example===
 
===Example===

Revision as of 07:59, 25 June 2018

iterator begin() noexcept;
(since {std})
const_iterator begin() const noexcept;
(since {std})
const_iterator cbegin() const noexcept;
(since {std})

Returns an iterator to the first element of the container.

If the container is empty, the returned iterator will be equal to end().

range-begin-end.svg

Contents

Parameters

(none)

Return value

Iterator to the first element

Complexity

Constant


Notes

Note that both iterator and const_iterator are Constant LegacyForwardIterators, and thus none of these methods return an iterator that can be used to mutate the elements of the container.

Example

See also

returns an iterator to the end
(public member function of std::{{{1}}}) [edit]