Boost.URL Logo

PrevUpHomeNext
pct_encoded_view::assign_to

Assign the range with percent-decoded applied to an existing string.

Synopsis
template<
    class MutableString>
MutableString&
assign_to(
    MutableString& s) const;
Description

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() );
Example
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";
}
Mandates
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:

Complexity

Linear in this->size(), plus s.assign( this->begin(), this->end() ).

Return Value

A string representing the entire contents of the decoded range.


PrevUpHomeNext