Difference between revisions of "Template:cpp/container/begin"
From cppreference.com
m (+inplace_vector() |
|||
(41 intermediate revisions by 8 users not shown) | |||
Line 1: | Line 1: | ||
− | {{ | + | {{#vardefine:cont|{{{1|inplace_vector}}}}}<!-- |
− | {{cpp/container/{{ | + | -->{{cpp/container/{{#var:cont}}/title|begin|cbegin}} |
− | {{# | + | {{cpp/container/{{#var:cont}}/navbar}} |
{{dcl begin}} | {{dcl begin}} | ||
− | {{ | + | {{#switch:{{#var:cont}} |
− | {{dcl | | + | |array= |
+ | {{dcl|num=1|since=c++11|notes={{mark constexpr since c++17}}| | ||
iterator begin() noexcept; | iterator begin() noexcept; | ||
}} | }} | ||
− | {{dcl | since=c++ | + | {{dcl|num=2|since=c++11|notes={{mark constexpr since c++17}}| |
− | + | ||
− | + | ||
− | {{ | + | |
− | + | ||
− | + | ||
const_iterator begin() const noexcept; | const_iterator begin() const noexcept; | ||
}} | }} | ||
− | {{dcl | since=c++17| | + | {{dcl|num=3|since=c++11|notes={{mark constexpr since c++17}}| |
− | constexpr const_iterator begin() const | + | const_iterator cbegin() const noexcept; |
+ | }} | ||
+ | |vector= | ||
+ | {{dcl|num=1|notes={{mark noexcept since c++11}}<br>{{mark constexpr since c++20}}| | ||
+ | iterator begin(); | ||
+ | }} | ||
+ | {{dcl|num=2|notes={{mark noexcept since c++11}}<br>{{mark constexpr since c++20}}| | ||
+ | const_iterator begin() const; | ||
}} | }} | ||
− | + | {{dcl|num=3|since=c++11|notes={{mark constexpr since c++20}}| | |
− | + | ||
− | {{dcl | | + | |
const_iterator cbegin() const noexcept; | const_iterator cbegin() const noexcept; | ||
}} | }} | ||
− | {{dcl | since=c++ | + | |inplace_vector= |
+ | {{dcl|num=1|since=c++26| | ||
+ | constexpr iterator begin() noexcept; | ||
+ | }} | ||
+ | {{dcl|num=2|since=c++26| | ||
+ | constexpr const_iterator begin() const noexcept; | ||
+ | }} | ||
+ | {{dcl|num=3|since=c++26| | ||
constexpr const_iterator cbegin() const noexcept; | constexpr const_iterator cbegin() const noexcept; | ||
}} | }} | ||
− | |||
− | |||
|span= | |span= | ||
− | + | {{dcl|num=1|since=c++20| | |
− | {{dcl |1= | + | |
constexpr iterator begin() const noexcept; | constexpr iterator begin() const noexcept; | ||
}} | }} | ||
− | {{dcl | | + | {{dcl|num=2|since=c++23| |
constexpr const_iterator cbegin() const noexcept; | constexpr const_iterator cbegin() const noexcept; | ||
}} | }} | ||
− | {{dcl | + | |flat_map|flat_multimap|flat_set|flat_multiset= |
− | + | {{dcl|num=1|since=c++23| | |
− | {{cpp/container/noexcept dcl | | + | iterator begin() noexcept; |
+ | }} | ||
+ | {{dcl|num=2|since=c++23| | ||
+ | const_iterator begin() const noexcept; | ||
+ | }} | ||
+ | {{dcl|num=3|since=c++23| | ||
+ | const_iterator cbegin() const noexcept; | ||
+ | }} | ||
+ | | | ||
+ | {{cpp/container/noexcept dcl|num=1|{{#var:cont}}|dcl= | ||
iterator begin() | iterator begin() | ||
}} | }} | ||
− | {{cpp/container/noexcept dcl | {{ | + | {{cpp/container/noexcept dcl|num=2|{{#var:cont}}|dcl= |
const_iterator begin() const | const_iterator begin() const | ||
}} | }} | ||
− | {{dcl | since={{cpp/std|{{ | + | {{dcl|num=3|since={{cpp/std|{{#var:cont}}|c++11}}| |
const_iterator cbegin() const noexcept; | const_iterator cbegin() const noexcept; | ||
}} | }} | ||
− | {{dcl end | + | }} |
+ | {{dcl end}} | ||
− | Returns an iterator to the first element of the {{# | + | Returns an iterator to the first element of the {{tt|{{#var:cont}}}}. |
− | If the {{# | + | If the {{tt|{{#var:cont}}}} is empty, the returned iterator will be equal to {{lc|end()}}. |
{{image|range-begin-end.svg}} | {{image|range-begin-end.svg}} | ||
Line 59: | Line 74: | ||
===Return value=== | ===Return value=== | ||
− | Iterator to the first element | + | Iterator to the first element. |
===Complexity=== | ===Complexity=== | ||
− | Constant | + | Constant. |
− | {{# | + | <!----> |
− | + | {{#ifexpr:{{cpp/container/if c++98|{{#var:cont}}|1|0}}or{{cpp/container/if set|{{#var:cont}}|1|0}}| | |
===Notes=== | ===Notes=== | ||
− | + | {{cpp/container/if set|{{#var:cont}}|{{cpp/container/constant iterator note}}}} | |
− | + | {{cpp/container/if c++98|{{#var:cont}}|<p>libc++ backports {{tt|cbegin()}} to C++98 mode.</p>}}}} | |
+ | <!----> | ||
===Example=== | ===Example=== | ||
− | {{#switch:{{ | + | {{#switch:{{#var:cont}} |
− | + | |deque|forward_list|list|vector={{cpp/container/begin/examples/sequence|{{#var:cont}}}} | |
− | # | + | |{{cpp/container/begin/examples/{{#var:cont}}}} |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | } | + | |
− | | | + | |
− | | | + | |
− | | | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | | | + | |
− | {{ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | // | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | | | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | {{ | + | |
− | # | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | } | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | }} | + | |
− | | | + | |
− | {{ | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | # | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
}} | }} | ||
===See also=== | ===See also=== | ||
− | |||
{{dsc begin}} | {{dsc begin}} | ||
− | {{dsc inc | cpp/container/dsc end |{{ | + | {{dsc inc|cpp/container/dsc end|{{#var:cont}}}} |
+ | {{dsc inc|cpp/iterator/dsc begin}} | ||
{{dsc end}} | {{dsc end}} |
Latest revision as of 05:07, 16 August 2024
constexpr iterator begin() noexcept; |
(1) | (since C++26) |
constexpr const_iterator begin() const noexcept; |
(2) | (since C++26) |
constexpr const_iterator cbegin() const noexcept; |
(3) | (since C++26) |
Returns an iterator to the first element of the inplace_vector
.
If the inplace_vector
is empty, the returned iterator will be equal to end().
Contents |
[edit] Parameters
(none)
[edit] Return value
Iterator to the first element.
[edit] Complexity
Constant.
[edit] Example
Template:cpp/container/begin/examples/inplace vector
[edit] See also
returns an iterator to the end (public member function of std::inplace_vector<T,N> )
| |
(C++11)(C++14) |
returns an iterator to the beginning of a container or array (function template) |