Difference between revisions of "Template:cpp/container/begin"
From cppreference.com
m (rm stray {{dcl begin}}) |
m (+inplace_vector() |
||
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:{{ | + | {{#switch:{{#var:cont}} |
|array= | |array= | ||
{{dcl|num=1|since=c++11|notes={{mark constexpr since c++17}}| | {{dcl|num=1|since=c++11|notes={{mark constexpr since c++17}}| | ||
Line 22: | Line 23: | ||
{{dcl|num=3|since=c++11|notes={{mark constexpr since c++20}}| | {{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; | ||
}} | }} | ||
|span= | |span= | ||
Line 41: | Line 52: | ||
}} | }} | ||
| | | | ||
− | {{cpp/container/noexcept dcl|num=1|{{ | + | {{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 53: | 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 68: | Line 79: | ||
Constant. | Constant. | ||
<!----> | <!----> | ||
− | {{#ifexpr:{{cpp/container/if c++98|{{ | + | {{#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|{{ | + | {{cpp/container/if set|{{#var:cont}}|{{cpp/container/constant iterator note}}}} |
− | {{cpp/container/if c++98|{{ | + | {{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) |