Boost.URL Logo

PrevUpHomeNext
segments::assign

Replace the contents of the container.

Synopsis
template<
    class FwdIt>
void
assign(
    FwdIt first,
    FwdIt last);
Description

This function replaces the contents with a range of percent-encoded strings. Each string must contain a valid percent-encoding or else an exception is thrown. The behavior is undefined if either argument is an iterator into *this. All iterators and references to elements of the container are invalidated, including the end iterator.

Requires
std::is_convertible< std::iterator_traits< FwdIt >::value_type, string_view >::value == true
Example
url u = parse_relative_uri( "/path/to/file.txt" );

segments se = u.segments();

std::vector< std::string > v = { "etc", "init.rc" };

se.insert( u.end() - 1, v.begin(), v.end() );

assert( u.encoded_path() == "/etc/init.rc") );
Exception Safety

Strong guarantee. Calls to allocate may throw. Exceptions thrown on invalid input.

Parameters

Name

Description

first

An iterator to the first element in the range

last

An iterator to one past the last element in the range

Exceptions

Type

Thrown On

std::invalid_argument

invalid percent-encoding


PrevUpHomeNext