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 标志
(函数)