Namespaces
Variants

std:: showpos, std:: noshowpos

From cppreference.net
< cpp ‎ | io ‎ | manip
Input/output manipulators
Floating-point formatting
Integer formatting
Boolean formatting
Field width and fill control
Other formatting
showpos noshowpos
Whitespace processing
Output flushing
Status flags manipulation
Time and money I/O
(C++11)
(C++11)
(C++11)
(C++11)
Quoted manipulator
(C++14)
定義先ヘッダ <ios>
(1)
std:: ios_base & noshowpos ( std:: ios_base & str ) ;
(2)

非負整数の出力におけるプラス記号 '+' の表示を有効または無効にします。入力には影響しません。

1) ストリーム str showpos フラグを有効にする。 str. setf ( std:: ios_base :: showpos ) を呼び出したかのように動作する。
2) ストリーム str showpos フラグを無効にします。これは str. unsetf ( std:: ios_base :: showpos ) を呼び出した場合と同様です。

これはI/Oマニピュレータであり、 out << std :: showpos のような式で、 out std::basic_ostream 型の場合に呼び出せる。または、 in >> std :: showpos のような式で、 in std::basic_istream 型の場合に呼び出せる。

目次

パラメータ

str - 参照するI/Oストリーム

戻り値

str (操作後のストリームへの参照)。

#include <iostream>
int main()
{
    std::cout
        << "showpos: " << std::showpos << 42 << ' ' << 3.14 << ' ' << 0 << '\n'
        << "noshowpos: " << std::noshowpos << 42 << ' ' << 3.14 << ' ' << 0 << '\n';
}

出力:

showpos: +42 +3.14 +0
noshowpos: 42 3.14 0

関連項目

指定された ios_base フラグをクリア
(関数)
指定された ios_base フラグを設定
(関数)