Difference between revisions of "Template:cpp/container/begin"
From cppreference.com
m (Behold the versioning (1)/(2)/(3). Testing...) |
m (+inplace_vector() |
||
(17 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
− | {{# | + | {{#vardefine:cont|{{{1|inplace_vector}}}}}<!-- |
− | + | -->{{cpp/container/{{#var:cont}}/title|begin|cbegin}} | |
− | }} | + | {{cpp/container/{{#var:cont}}/navbar}} |
− | {{cpp/container/{{ | + | |
{{dcl begin}} | {{dcl begin}} | ||
− | {{#switch:{{ | + | {{#switch:{{#var:cont}} |
− | {{dcl | + | |array= |
− | | | + | {{dcl|num=1|since=c++11|notes={{mark constexpr since c++17}}| |
iterator begin() noexcept; | iterator begin() noexcept; | ||
− | |||
− | |||
}} | }} | ||
− | {{dcl | + | {{dcl|num=2|since=c++11|notes={{mark constexpr since c++17}}| |
− | | | + | |
const_iterator begin() const noexcept; | const_iterator begin() const noexcept; | ||
− | |||
− | |||
}} | }} | ||
− | {{dcl | + | {{dcl|num=3|since=c++11|notes={{mark constexpr since c++17}}| |
− | | | + | |
const_iterator cbegin() const noexcept; | const_iterator cbegin() const noexcept; | ||
− | |||
− | |||
}} | }} | ||
|vector= | |vector= | ||
− | {{dcl | + | {{dcl|num=1|notes={{mark noexcept since c++11}}<br>{{mark constexpr since c++20}}| |
− | | | + | |
iterator begin(); | iterator begin(); | ||
− | |||
− | |||
− | |||
− | |||
}} | }} | ||
− | {{dcl | + | {{dcl|num=2|notes={{mark noexcept since c++11}}<br>{{mark constexpr since c++20}}| |
− | | | + | |
const_iterator begin() const; | const_iterator begin() const; | ||
− | |||
− | |||
− | |||
− | |||
}} | }} | ||
− | {{dcl | + | {{dcl|num=3|since=c++11|notes={{mark constexpr since c++20}}| |
− | | | + | |
const_iterator cbegin() const noexcept; | const_iterator cbegin() const noexcept; | ||
− | | | + | }} |
+ | |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| | + | {{dcl|num=1|since=c++20| |
constexpr iterator begin() const noexcept; | constexpr iterator begin() const noexcept; | ||
}} | }} | ||
− | |{{dcl begin}} | + | {{dcl|num=2|since=c++23| |
− | {{cpp/container/noexcept dcl|num=1|{{ | + | constexpr const_iterator cbegin() const noexcept; |
+ | }} | ||
+ | |flat_map|flat_multimap|flat_set|flat_multiset= | ||
+ | {{dcl|num=1|since=c++23| | ||
+ | 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|num=2|{{ | + | {{cpp/container/noexcept dcl|num=2|{{#var:cont}}|dcl= |
const_iterator begin() const | const_iterator begin() const | ||
}} | }} | ||
− | {{dcl|num=3|since={{cpp/std|{{ | + | {{dcl|num=3|since={{cpp/std|{{#var:cont}}|c++11}}| |
const_iterator cbegin() const noexcept; | const_iterator cbegin() const noexcept; | ||
}} | }} | ||
Line 63: | Line 64: | ||
{{dcl end}} | {{dcl end}} | ||
− | Returns an iterator to the first element of the {{tt|{{ | + | Returns an iterator to the first element of the {{tt|{{#var:cont}}}}. |
− | If the {{tt|{{ | + | 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 77: | Line 78: | ||
===Complexity=== | ===Complexity=== | ||
Constant. | Constant. | ||
− | {{# | + | <!----> |
− | + | {{#ifexpr:{{cpp/container/if c++98|{{#var:cont}}|1|0}}or{{cpp/container/if set|{{#var:cont}}|1|0}}| | |
+ | ===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|{{ | + | |deque|forward_list|list|vector={{cpp/container/begin/examples/sequence|{{#var:cont}}}} |
− | |{{cpp/container/begin/examples/{{ | + | |{{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 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) |