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

std::sub_match::operators (std::sub_match::str)

operator string_type() const;

(1)

?

string_type str() const;

(2)

?

转换为基础对象的对象。std::basic_string类型。

第一个版本是隐式转换,三是显式转换。

参数

%280%29

返回值

的对象返回匹配的字符序列。std::basic_string类型。如果matched成员是假的然后返回空字符串。

复杂性

与基本字符序列的长度成线性。

二次

代码语言:javascript
复制
#include <iostream>
#include <regex>
#include <string>
int main()
{
  std::ssub_match sm;
  std::string s = sm;  // implicit conversion
  std::cout << s.length() << '\n';
}

二次

产出:

二次

代码语言:javascript
复制
?0?

二次

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

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

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com