std::operator<<,>>
提供: cppreference.com
< cpp | string | basic string
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
Defined in header <string>
|
||
template <class CharT, class Traits, class Allocator> std::basic_ostream<CharT, Traits>& |
(1) | |
template <class CharT, class Traits, class Allocator> std::basic_istream<CharT, Traits>& |
(2) | |
まず、std::basic_ostream::sentryオブジェクトをフラッシュネクタイを()を構築する 'Dストリームエラーのために必要かどうかをチェックします。監視オブジェクトは、直ちにfalse、を返して終了します..場合
Original:
First, constructs a std::basic_ostream::sentry object, which flushes the tie()'d stream if necessary and checks for errors. If the sentry object returns false, exits immediately.
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.
その後、監視オブジェクトを返した場合true、num_put::put()のステージ3と同様にして、出力形式のパディングを決定.
Original:
Afterwards, if the sentry object returns true, determines the output format padding in the same manner as stage 3 of num_put::put().
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.
その後
str
まるでos
を呼び出すことにより、出力ストリーム、os.rdbuf()->sputn(seq, n)に結果のシーケンス(n=std::max(os.width(), str.size())プラスパディングの内容)から、各文字を格納しますOriginal:
Then stores each character from the resulting sequence (the contents of
str
plus padding) to the output stream os
as if by calling os.rdbuf()->sputn(seq, n), where n=std::max(os.width(), str.size())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.
最後に、os.width(0)呼び出し.
2) Original:
Finally, calls os.width(0).
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.
まず、std::basic_istream::sentryフラグがクリアされた場合を除き、必要に応じて抽出して捨てるならDストリーム 'すべての先行する空白文字をios_base::skipwsオブジェクトをフラッシュタイ()を構築し、エラーがないかチェックします。監視オブジェクトは、直ちにfalse、を返して終了します..場合
Original:
First, constructs a std::basic_istream::sentry object, which flushes the tie()'d stream if necessary, extracts and discards all leading whitespace characters unless the ios_base::skipws flag was cleared, and checks for errors. If the sentry object returns false, exits immediately.
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.
その後、監視オブジェクトを返した場合true、
str
とstr.erase()クリアされますOriginal:
Afterwards, if the sentry object returns true, clears
str
with str.erase()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.
次のいずれかの条件がtrueになるまで続いて、
is
たかのようにstr
str.append(1, c)を付加それらから文字を読み取りますOriginal:
Then reads characters from
is
and appends them to str
as if by str.append(1, c), until one of the following conditions becomes true: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.
-
N
が、そうでなければN
is.width()
ある場合is.width() > 0
がN
ですstr.max_size()
文字が読み取られますOriginal:N
characters are read, whereN
isis.width()
ifis.width() > 0
, otherwiseN
isstr.max_size()
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - ファイル終了条件は、ストリーム
is
で発生しますOriginal:the end-of-file condition occurs in the streamis
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions. - std::isspace(c,is.getloc())
c
内の次の文字is
(この空白文字が入力ストリームに残っている)が真である.Original:std::isspace(c,is.getloc()) is true for the next characterc
inis
(this whitespace character remains in the input stream).The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
文字が次に抽出されていない場合はstd::ios::failbit
is
がスローされることがありますstd::ios_base::failure、上に設定されています.Original:
If no characters are extracted then std::ios::failbit is set on
is
, which may throw std::ios_base::failure.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.
最後に、os.width(0)呼び出し、std::basic_istream::sentryオブジェクトを破棄します.
Original:
Finally, calls os.width(0) and destroys the std::basic_istream::sentry object.
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.
目次 |
[編集] 例外
1)例外が出力中に投げられたときにstd::ios_base::failureをスローすることがあります.
2) Original:
may throw std::ios_base::failure if an exception is thrown during output.
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.
文字がstd::ios_base::failure(例えば、ストリームがファイルの末尾にある、または空白文字のみで構成されています)から抽出されていない場合、または例外が入力中に投げられたときに
is
をスローすることがあります.Original:
may throw std::ios_base::failure if no characters are extracted from
is
(e.g the stream is at end of file, or consists of whitespace only), or if an exception is thrown during input.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.
[編集] パラメータ
os | - | 文字出力ストリーム
Original: a character output stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
is | - | 文字入力ストリーム
Original: a character input stream The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
str | - | 文字列を挿入または抽出される
Original: the string to be inserted or extracted The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集] 値を返します
1) os
2) is
[編集] 例
このコードを実行します
#include <iostream> #include <string> int main() { std::string greeting = "Hello, whirled!" std::cout << greeting << '\n'; }
出力:
Hello, whirled!