Assign the range with percent-decoded applied to an existing string.
template< class MutableString> MutableString& assign_to( MutableString& s) const;
This function applies percent-decoding to each character in the referenced
buffer and assigns it to s
which must satisfy the requirements of MutableString.
In particular this expression must be valid:
s.assign( this->begin(), this->end() );
void f( pct_encoded_view s ) { thread_local static std::string tmp; // Existing capacity of `tmp` will be reused first. // If this function is called repeatedly, then the // following line will almost never perform a // memory allocation: s.assign_to( tmp ); std::cout << tmp << "\n"; }
is_mutable_string_v< MutableString >
Depending on the implementation of MutableString
this allows the caller to recycle capacity that resides in an already-existing
container when applying percent-decoding, as shown in this example:
Linear in this->size()
,
plus s.assign( this->begin(), this->end() )
.
A string representing the entire contents of the decoded range.