名前空間
変種
操作

std::num_put::put, std::num_put::do_put

提供: cppreference.com
< cpp‎ | locale‎ | num put

 
 
ローカライゼーションライブラリ
ロケールおよびファセット
Original:
Locales and facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
locale
文字分類
Original:
Character classification
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
変換
Original:
Conversions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファセットカテゴリの基底クラスです
Original:
Facet category base classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ファセットカテゴリ
Original:
Facet categories
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
ロケール固有のファセット
Original:
Locale-specific facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
コー​​ド変換ファセット
Original:
Code conversion facets
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
codecvt_utf8(C++11)
codecvt_utf16(C++11)
Cロケール
Original:
C locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
 
std::num_put
メンバ関数
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.
num_put::num_put
num_put::~num_put
num_put::put
num_put::do_put
 
Defined in header <locale>
public:

iter_type put( iter_type out, std::ios_base& str, char_type fill, bool v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, long v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, long long v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, unsigned long v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, unsigned long long v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, double v) const;
iter_type put( iter_type out, std::ios_base& str, char_type fill, long double v) const;

iter_type put( iter_type out, std::ios_base& str, char_type fill, const void* v) const;
(1)
protected:

iter_type do_put( iter_type out, std::ios_base& str, char_type fill, bool v) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, long v) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, long long v) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, unsigned long) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, unsigned long long) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, double v) const;
iter_type do_put( iter_type out, std::ios_base& str, char_type fill, long double v) const;

iter_type do_put( iter_type out, std::ios_base& str, char_type fill, const void* v) const;
(2)
1)
パブリックメンバ関数、最派生クラスのプロテクト仮想メンバ関数を呼び出しdo_put.
Original:
public member function, calls the protected virtual member function do_put of the most derived class.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2)
書式化フラグoutとストリームvに吹き込まれたロケールのstr.flags()std::numpunctファセットによって、要求されたフォーマットされた出力シーケンスに文字を書き込みstd::ctypestrの値を表しているか、。この関数は、std::cout << n;など、すべてのフォーマットされた出力ストリーム演算子によって呼び出され、.
Original:
writes characters to the output sequence out which represent the value of v, formatted as requested by the formatting flags str.flags() and the std::numpunct and std::ctype facets of the locale imbued in the stream str. This function is called by all formatted output stream operators, such as std::cout << n;.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
変換は、次の4つの段階で行われます
Original:
Conversion occurs in four stages
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

目次

[編集] ステージ1:変換指定子の選択

  • I / Oフォーマットフラグがあるかのようにすることによって、得られる
    Original:
    I/O format flags are obtained, as if by
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
fmtflags basefield = (str.flags() & std::ios_base::basefield);
fmtflags uppercase = (str.flags() & std::ios_base::uppercase);
fmtflags floatfield = (str.flags() & std::ios_base::floatfield);
fmtflags showpos = (str.flags() & std::ios_base::showpos);
fmtflags showbase = (str.flags() & std::ios_base::showbase);
  • vのタイプはboolある場合
    Original:
    If the type of v is bool
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • *boolalpha == 0場合は、vを入力するintを変換し、整数出力を行う.
    Original:
    * If boolalpha == 0, then converts v to type int and performs integer output.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • *もしboolalpha != 0std::use_facet<std::numpunct<charT>>(str.getloc()).truename()場合v == trueまたはstd::use_facet<std::numpunct<charT>>(str.getloc()).falsename()v == falseあれば取得し、coutと、その文字列の各々の連続した​​文字*out++ = cを出力します。それ以上の処理はこのケースでは行われず、関数はoutを返します。.
    Original:
    * If boolalpha != 0 obtains std::use_facet<std::numpunct<charT>>(str.getloc()).truename() if v == true or std::use_facet<std::numpunct<charT>>(str.getloc()).falsename() if v == false, and outputs each successive character c of that string to out with *out++ = c. No further processing is done in this case, the function returns out.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vの型は整数型である場合は、次の5つの適用可能な最初の選択肢が選択されています
    Original:
    If the type of v is an integer type, the the first applicable choice of the following five is selected:
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
basefield == oct場合は、変換指定子%oを使用します
Original:
If basefield == oct, will use conversion specifier %o
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basefield == hex && !uppercase場合は、変換指定子%xを使用します
Original:
If basefield == hex && !uppercase, will use conversion specifier %x
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
basefield == hex場合は、変換指定子%Xを使用します
Original:
If basefield == hex, will use conversion specifier %X
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vの種類は署名されている場合は、変換指定子%dを使用します
Original:
If the type of v is signed, will use conversion specifier %d
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
vの型がunsignedである場合、変換指定子%uを使用します
Original:
If the type of v is unsigned, will use conversion specifier %u
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • 整数型の場合、長さ修飾子は、変換仕様に必要に応じて添加場合です:llongおよびunsigned longlllong longおよびunsigned long long.
    Original:
    For integer types, length modifier is added to the conversion specification if necessary: l for long and unsigned long, ll for long long and unsigned long long.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vのタイプが浮動小数点型である場合は、次の5つの適用可能な最初の選択肢が選択されています
    Original:
    If the type of v is a floating-point type, the the first applicable choice of the following five is selected:
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
floatfield == std::ios_base::fixed場合は、変換指定子%fを使用します
Original:
If floatfield == std::ios_base::fixed, will use conversion specifier %f
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
floatfield == std::ios_base::scientific && !uppercase場合は、変換指定子%eを使用します
Original:
If floatfield == std::ios_base::scientific && !uppercase, will use conversion specifier %e
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
floatfield == std::ios_base::scientific場合は、変換指定子%Eを使用します
Original:
If floatfield == std::ios_base::scientific, will use conversion specifier %E
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
floatfield == (std::ios_base::fixed | std::ios_base::scientific) && !uppercase場合は、変換指定子を使用します%a(C + + 11以来)
Original:
If floatfield == (std::ios_base::fixed | std::ios_base::scientific) && !uppercase, will use conversion specifier %a (C + + 11以来)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
floatfield == std::ios_base::fixed | std::ios_base::scientific場合は、変換指定子を使用します%A(C + + 11以来)
Original:
If floatfield == std::ios_base::fixed | std::ios_base::scientific, will use conversion specifier %A (C + + 11以来)
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
!uppercase場合は、変換指定子%gを使用します
Original:
If !uppercase, will use conversion specifier %g
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
そうでない場合は、変換指定子%Gを使用します
Original:
otherwise, will use conversion specifier %G
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • *vのタイプがlong doubleの場合には、長さ修飾Lは、変換指定子に追加され.
    Original:
    * If the type of v is long double, the length modifier L is added to the conversion specifier.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • *さらにfloatfield != (ios_base::fixed | ios_base::scientific)が、その後精度修飾子が追加された場合、str.precision()に設定されています
    Original:
    * Additionally, if floatfield != (ios_base::fixed | ios_base::scientific), then precision modifier is added, set to str.precision()
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • showbaseが設定されている場合、整数と浮動小数点の両方タイプの場合、修飾#が付加されます。 showposが設定されている場合、修飾+が前に付加されます.
    Original:
    For both integer and floating-point types, if showbase is set, the modifier # is prepended. If showpos is set, the modifier + is prepended.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • vのタイプがvoid*である場合は、変換指定子%pを使用します
    Original:
    If the type of v is void*, will use conversion specifier %p
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 狭い文字列はstd::printf(spec, v)が選択した変換指定子である "C"ロケールでspecへの呼び出しと同じように作成された.
    Original:
    A narrow character string is created as if by a call to std::printf(spec, v) in the "C" locale, where spec is the chosen conversion specifier.
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] ステージ2:ロケール固有の変換

  • 小数点c以外のステージ1で得られたすべての文字'.'は、CharT呼び出してstd::use_facet<std::ctype<CharT>>(str.getloc()).widen(c)に変換されます.
    Original:
    Every character c obtained in Stage 1, other than the decimal point '.', is converted to CharT by calling std::use_facet<std::ctype<CharT>>(str.getloc()).widen(c).
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 算術型の場合は、std::use_facet<std::numpunct<CharT>>(str.getloc()).thousands_sep()から得られた桁区切り文字は、std::use_facet<std::numpunct<CharT>>(str.getloc()).grouping()が提供するグループルールに従ってシーケンスに挿入されます
    Original:
    For arithmetic types, the thousands separator character, obtained from std::use_facet<std::numpunct<CharT>>(str.getloc()).thousands_sep(), is inserted into the sequence according to the grouping rules provided by std::use_facet<std::numpunct<CharT>>(str.getloc()).grouping()
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
  • 小数点文字('.'std::use_facet<std::numpunct<CharT>>(str.getloc()).decimal_point()に置き換えられます
    Original:
    Decimal point characters ('.') are replaced by std::use_facet<std::numpunct<CharT>>(str.getloc()).decimal_point()
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] ステージ3:パディング

  • 調整フラグがstd::fmtflags adjustfield = (flags & (std::ios_base::adjustfield))たかのようにして得られ、次のように、パディングの場所を識別するために検査されます
    Original:
    The adjustment flag is obtained as if by std::fmtflags adjustfield = (flags & (std::ios_base::adjustfield)) and examined to identify padding location, as follows
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.
adjustfield == std::ios_base::left場合は、パッドの後になります
Original:
If adjustfield == std::ios_base::left, will pad after
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
adjustfield == std::ios_base::right場合は、前にパッドでしょう
Original:
If adjustfield == std::ios_base::right, will pad before
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
adjustfield == std::ios_base::internalと符号文字が表現で発生した場合、記号の後のパッドでしょう
Original:
If adjustfield == std::ios_base::internal and a sign character occurs in the representation, will pad after the sign
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
adjustfield == std::ios_base::internalとステージ1の表現が0xまたは0Xで始めた場合、xまたはX
Original:
If adjustfield == std::ios_base::internal and Stage 1 representation began with 0x or 0X, will pad after the x or X
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
後のパッドでしょう。そうでなければ、前にパッドだろう
Original:
otherwise, will pad before
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
  • str.width()が非ゼロであるなら(例えばstd::setwは単に使用されていました)と第2ステージの後、チャートの数が少ないstr.width()未満である場合、fill文字のコピーがstr.width()にシーケンスの長さを持って来るためにパディングによって示される位置に挿入されます。
    Original:
    If str.width() is non-zero (e.g. std::setw was just used) and the number of CharT's after Stage 2 is less than str.width(), then copies of the fill character are inserted at the position indicated by padding to bring the length of the sequence to str.width().
    The text has been machine-translated via Google Translate.
    You can help to correct and verify the translation. Click here for instructions.

[編集] ステージ4:出力

ステージ3からグラフの系列から毎週連続する文字c*out++ = cたかのように出力されます.
Original:
Every successive character c from the sequence of CharT's from Stage 3 is output as if by *out++ = c.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] パラメータ

out -
上書きされた最初の文字を指すイテレータ
Original:
iterator pointing to the first character to be overwritten
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
str -
から書式情報を取得するためのストリーム
Original:
stream to retrieve the formatting information from
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
fill -
結果がフィールド幅になるようにパディングする必要があるときにパディング文字は使用しました
Original:
padding character used when the results needs to be padded to the field width
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
v -
文字列と出力に変換する値
Original:
value to convert to string and output
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集] 値を返します

out

[編集] ノート

変換指定#o(たとえばstd::showbasestd::octの組み合わせから生じる)によって生成され、先​​頭にゼロをパディング文字としてカウントされません.
Original:
The leading zero generated by the conversion specification #o (resulting from the combination of std::showbase and std::oct for example) is not counted as a padding character.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

グローバルなロケールを使用して番号を出力する
Original:
Output a number using global locale
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

#include <iostream>
#include <locale>
 
int main()
{
    auto &facet = std::use_facet<std::num_put<char>>(std::locale());
    facet.put(std::cout, std::cout, '0', 2.71);
    std::cout << '\n';
}

Output:

2,71

[編集] も参照してください

挿入してデータをフォーマットします
Original:
inserts formatted data
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

(パブリックメンバ関数of std::basic_ostream) [edit]