名前空間
変種
操作

std::sub_match<BidirIt>::operator string_type, std::sub_match<BidirIt>::str

提供: cppreference.com
< cpp‎ | regex‎ | sub match
operator string_type() const;
(1)
string_type str() const;
(2)

ベースとなる std::basic_string 型のオブジェクトに変換します。

最初のバージョンは暗黙の変換、2番目は明示的な関数です。

目次

[編集] 引数

(なし)

[編集] 戻り値

ベースとなる std::basic_string 型のオブジェクトとしてマッチした文字シーケンスを返します。 matched メンバが false の場合は空文字列が返されます。

[編集] 計算量

ベースとなる文字シーケンスの長さに比例。

[編集]

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

出力:

​0​