Namespaces
Variants
Views
Actions

std::sub_match::operator string_type, std::sub_match::str

From cppreference.com
< cpp‎ | regex‎ | sub match
Revision as of 17:21, 26 June 2013 by P12 (Talk | contribs)

operator string_type() const;
(1)
string_type str() const;
(2)

Converts to an object of the underlying std::basic_string type.

The first version is an implicit conversion, the second one is explicit.

Contents

Parameters

(none)

Return value

Returns the matched character sequence as an object of the underlying std::basic_string type. If the matched member is false then the empty string is returned.

Complexity

Linear in the length of the underlying character sequence.

Example

std::ssub_match sm;
std::string s = sm;  // implicit conversion
std::cout << s.length() << '\n';

Output:

​0​