std::basic_string::shrink_to_fit
提供: cppreference.com
< cpp | string | basic string
![]() | このページは、Google 翻訳を使って英語版から機械翻訳されました。 翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
void shrink_to_fit(); | (C++11およびそれ以降) | |
未使用容量の要求が除去.
Original:
Requests the removal of unused capacity.
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.
それは
capacity
にsize
を削減するための拘束力のない要求です。要求が満たされているなら、それは実装に依存します. Original:
It is a non-binding request to reduce
capacity
to size
. It depends on the implementation if the request is fulfilled. 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 <iostream>#include <string>int main(){std::string s;std::cout<<"Default-constructed capacity is "<< s.capacity()<<'\n'; s.resize(100);std::cout<<"Capacity of a 100-element string is "<< s.capacity()<<'\n'; s.clear();std::cout<<"Capacity after clear() is "<< s.capacity()<<'\n'; s.shrink_to_fit();std::cout<<"Capacity after shrink_to_fit() is "<< s.capacity()<<'\n';}
出力:
Default-constructed capacity is 0 Capacity of a 100-element string is 100 Capacity after clear() is 100 Capacity after shrink_to_fit() is 0
[編集]参照
文字数を返します (パブリックメンバ関数) | |
現在割り当てられているストレージに保持することができる文字の数を返します Original: returns the number of characters that can be held in currently allocated storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) |