名前空間
変種
操作

std::operator<<,>>

提供: cppreference.com
< cpp‎ | string‎ | basic string

 
 
ストリングスライブラリ
NULLで終わる文字列
Original:
Null-terminated strings
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
バイト文字列
文字列をマルチバイト
ワイド文字列
クラス
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string
char_traits
 
std::basic_string
メンバ関数
Original:
Member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::basic_string
basic_string::operator=
basic_string::assign
basic_string::get_allocator
要素アクセスの循環参照を解除するために使用されている
Original:
Element access
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::at
basic_string::operator[]
basic_string::front(C++11)
basic_string::back(C++11)
basic_string::data
basic_string::c_str
イテレータ
Original:
Iterators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::begin
basic_string::cbegin

(C++11)
basic_string::end
basic_string::cend

(C++11)
basic_string::rbegin
basic_string::crbegin

(C++11)
basic_string::rend
basic_string::crend

(C++11)
容量
Original:
Capacity
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::empty
basic_string::size
basic_string::length
basic_string::max_size
basic_string::reserve
basic_string::capacity
basic_string::shrink_to_fit(C++11)
操作
Original:
Operations
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::clear
basic_string::insert
basic_string::erase
basic_string::push_back
basic_string::pop_back(C++11)
basic_string::append
basic_string::operator+=
basic_string::compare
basic_string::replace
basic_string::substr
basic_string::copy
basic_string::resize
basic_string::swap
検索
Original:
Search
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::find
basic_string::rfind
basic_string::find_first_of
basic_string::find_first_not_of
basic_string::find_last_of
basic_string::find_last_not_of
定数
Original:
Constants
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basic_string::npos
非メンバ関数
Original:
Non-member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
operator+
operator==
operator!=
operator<
operator>
operator<=
operator>=
swap(std::basic_string)
operator<<
operator>>
getline
stoi
stol
stoll
(C++11)
(C++11)
(C++11)
stoul
stoull
(C++11)
(C++11)
stof
stod
stold
(C++11)
(C++11)
(C++11)
to_string(C++11)
to_wstring(C++11)
ヘルパークラス
Original:
Helper classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
hash<std::string>
hash<std::wstring>
hash<std::u32string>
hash<std::u16string>
(C++11)
 
Defined in header <string>
template <class CharT, class Traits, class Allocator>

std::basic_ostream<CharT, Traits>&
    operator<<(std::basic_ostream<CharT, Traits>& os,

               const std::basic_string<CharT, Traits, Allocator>& str);
(1)
template <class CharT, class Traits, class Allocator>

std::basic_istream<CharT, Traits>&
    operator>>(std::basic_istream<CharT, Traits>& is,

               std::basic_string<CharT, Traits, Allocator>& str);
(2)
1)
まず、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.
その後、監視オブジェクトを返した場合truenum_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.
その後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.
最後に、os.width(0)呼び出し.
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.
2)
まず、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.
その後、監視オブジェクトを返した場合truestrstr.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.
次のいずれかの条件がtrueになるまで続いて、isたかのようにstrstr.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.
  • Nが、そうでなければNis.width()ある場合is.width() > 0Nですstr.max_size()文字が読み取られます
    Original:
    N characters are read, where N is is.width() if is.width() > 0, otherwise N is str.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 stream is
    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 character c in is (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::failbitisがスローされることがあります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.
最後に、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.

目次

[編集] 例外

1)
例外が出力中に投げられたときにstd::ios_base::failureをスローすることがあります.
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.
2)
文字が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.

[編集] パラメータ

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';
}

Output:

Hello, whirled!