「cpp/locale/codecvt/length」の版間の差分
提供: cppreference.com
細 (1版:Translate from the English version) |
細 |
||
(2人の利用者による、間の4版が非表示) | |||
1行: | 1行: | ||
− | + | {{cpp/codecvt/title|lengthdo_length}} | |
− | {{cpp/codecvt/title|length | + | |
{{cpp/locale/codecvt/navbar}} | {{cpp/locale/codecvt/navbar}} | ||
− | {{ | + | {{begin}} |
− | {{ | + | {{header | locale}} |
− | {{ | + | {{| num=1 | 1= |
public: | public: | ||
− | int length( | + | int length( & state, |
− | const | + | const * from, |
− | const | + | const * from_end, |
− | std::size_t max ) const | + | std::size_t max ) const |
}} | }} | ||
− | {{ | + | {{| num=2 | 1= |
protected: | protected: | ||
− | int do_length( | + | int do_length( & state, |
− | + | const * from, | |
− | + | const * from_end, | |
− | + | std::size_t max ) const | |
}} | }} | ||
− | {{ | + | {{end}} |
− | 1 | + | 1public {{tt|do_length}} |
− | 2 | + | 2{{tt|}} {{tt|[from, from_end)}} {{tt|}} {{tt|max}} {{tt|internT}} {{tt|externT}} {{tt|[to, to+max)}} {{c|do_in(state, from, from_end, from, to, to+max, to)}} {{tt|}} |
− | === | + | ====== |
− | + | {{c|from_end-from}} {{tt|max}} {{tt|internT}} {{|do_in}} {{tt|}} | |
− | + | {{c|std::codecvt<char, char, std::mbstate_t>}} {{c|std::min(max, from_end-from)}} | |
===例=== | ===例=== | ||
+ | |||
{{example | {{example | ||
| | | | ||
36行: | 36行: | ||
#include <string> | #include <string> | ||
#include <iostream> | #include <iostream> | ||
+ | |||
int main() | int main() | ||
{ | { | ||
53行: | 54行: | ||
}} | }} | ||
− | === | + | ====== |
− | {{ | + | {{begin}} |
− | {{ | + | {{| cpp/locale/codecvt/do_in}} |
− | {{ | + | {{end |
+ | |||
+ | }} |
2019年6月2日 (日) 08:14時点における最新版
ヘッダ <locale> で定義
|
||
public: int length( StateT& state, |
(1) | |
protected: virtual int do_length( StateT& state, |
(2) | |
1) public メンバ関数。 最も派生したクラスのメンバ関数
do_length
を呼びます。2) 指定された初期変換状態
state
が与えられたとき、 [from, from_end)
によって定義される文字配列の externT
文字から、最大 max
個の internT
文字への変換を試み、そのような変換が消費するであろう externT
文字の個数を返します。 何らかの架空の出力バッファ [to, to+max)
に対して do_in(state, from, from_end, from, to, to+max, to) を実行したかのように、 state
を変更します。[編集] 戻り値
from_end-from 個の文字がすべて消費されるか、 max
個の internT
文字が生成されるか、変換エラーが発生するまで、 do_in() によって変換された場合に消費されるであろう externT
の文字数。
変換しない std::codecvt<char, char, std::mbstate_t> の特殊化は std::min(max, from_end-from) を返します。
[編集] 例
Run this code
#include <locale> #include <string> #include <iostream> int main() { // narrow multibyte encoding