命名空间
变体
操作

std::showpoint, std::noshowpoint

来自 cppreference.cn
< cpp‎ | io‎ | manip
 
 
 
输入/输出操纵符
浮点数格式化
showpointnoshowpoint
整数格式化
布尔格式化
字段宽度和填充控制
其他格式化
空白处理
输出刷新
(C++20)  

状态标志操作
时间和货币 I/O
(C++11)
(C++11)
(C++11)
(C++11)
引用操纵符
(C++14)
 
定义于头文件 <ios>
std::ios_base& showpoint( std::ios_base& str );
(1)
std::ios_base& noshowpoint( std::ios_base& str );
(2)

启用或禁用在浮点数输出中无条件包含小数点字符。对输入没有影响。

1) 在流 str 中启用 showpoint 标志,如同调用 str.setf(std::ios_base::showpoint) 一样。
2) 在流 str 中禁用 showpoint 标志,如同调用 str.unsetf(std::ios_base::showpoint) 一样。

这是一个 I/O 操纵符,可以与表达式(例如 out << std::showpoint,对于任何 out 类型为 std::basic_ostream 的情况)或表达式(例如 in >> std::showpoint,对于任何 in 类型为 std::basic_istream 的情况)一起调用。

用作小数点的字符由在输出时注入到流中的 locale 的 numpunct facet 确定,如 std::num_put::put 中所述。

目录

[编辑] 参数

str - I/O 流的引用

[编辑] 返回值

str(操作后的流的引用)。

[编辑] 示例

#include <iostream>
 
int main()
{
    std::cout << "1.0 with showpoint: " << std::showpoint << 1.0 << '\n'
              << "1.0 with noshowpoint: " << std::noshowpoint << 1.0 << '\n';
}

输出

1.0 with showpoint: 1.00000
1.0 with noshowpoint: 1

[编辑] 参见

清除指定的 ios_base 标志
(函数) [编辑]
设置指定的 ios_base 标志
(函数) [编辑]