首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

operator<<(std::basic_string_view)

Defined in header <string_view>

template <class CharT, class Traits> std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, std::basic_string_view <CharT, Traits> v);

(since C++17)

表现为FormattedOutputFunction.在构造和检查哨兵对象之后,确定输出格式填充如下:

A%29如果v.size()不少于os.width(),使用范围[v.begin(), v.end())否则为b%29,则为(os.flags() & ios_base::adjustfield) == ios_base::left、地点os.width()-v.size()的副本os.fill()字符序列c%29之后的字符,否则,放置os.width()-v.size()的副本os.fill()字符序列之前的字符

然后存储结果序列%28中的每个字符v加上将%29填充到输出流os好像通过打电话os.rdbuf()->sputn(seq, n),在哪里n=std::max(os.width(), str.size())...

最后,呼叫os.width(0)取消…的影响std::setw如果有的话。

例外

可抛std::ios_base::failure如果在输出期间抛出异常。

参数

os

-

a character output stream

v

-

the view to be inserted

返回值

os...

另见

operator<<operator>>

performs stream input and output on strings (function template)

代码语言:txt
复制
 © cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

扫码关注腾讯云开发者

领取腾讯云代金券