std::array::back
提供: cppreference.com
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
reference back(); |
(C++11およびそれ以降) | |
const_reference back() const; |
(C++11およびそれ以降) | |
コンテナ内の最後の要素への参照を返します.
Original:
Returns reference to the last element in the container.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
空の容器に
back
を呼び出すと、定義されていません.Original:
Calling
back
on an empty container is undefined.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] パラメータ
(なし)
Original:
(none)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 値を返します
最後の要素への参照
Original:
reference to the last element
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 複雑
定数
Original:
Constant
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] ノート
コンテナ
c
、発現return c.back();は{ auto tmp = c.end(); --tmp; return *tmp; }に相当しますOriginal:
For a container
c
, the expression return c.back(); is equivalent to { auto tmp = c.end(); --tmp; return *tmp; }The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
次のコードは、
back
の最後の要素を表示するためにstd::array<char>を使用しています
Original:
The following code uses
back
to display the last element of a std::array<char>:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
このコードを実行します
#include <array> #include <iostream> int main() { std::array<char> letters {'o', 'm', 'g', 'w', 't', 'f'}; if (!letters.empty()) { std::cout << "The last character is: " << letters.back() << '\n'; } }
出力:
The last character is f
[編集] も参照してください
最初の要素にアクセスします Original: access the first element The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |