Boost.URL Logo

PrevUpHomeNext
segments_encoded::insert (3 of 3 overloads)

Insert a range of segments.

Synopsis
template<
    class FwdIt>
iterator
insert(
    iterator before,
    FwdIt first,
    FwdIt last);
Description

This function inserts 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 references and iterators starting from the newly inserted elements and up to and including the last element and end iterators are invalidated.

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

segments_encoded se = u.encoded_segments();

std::vector< std::string > v = { "to", "the" };

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

assert( u.encoded_path() == "/path/to/the/file.txt") );
Remarks

Behavior is undefined if any elements of the range belong to the container

Exception Safety

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

Return Value

An iterator to one past the last newly inserted element or before if the range is empty.

Parameters

Name

Description

before

An iterator before which the new element should be inserted.

first

An iterator to the first element to insert.

last

An iterator to one past the last element to insert.

Exceptions

Type

Thrown On

std::invalid_argument

invalid percent-encoding


PrevUpHomeNext