Boost.URL Logo

PrevUpHomeNext
segments_encoded::insert (2 of 3 overloads)

Insert a range of segments.

Synopsis
iterator
insert(
    iterator before,
    std::initializer_list< string_view > init);
Description

This function inserts a range of percent-encoded strings passed as an initializer-list. Each string must contain a valid percent-encoding or else an exception is thrown. All references and iterators starting from the newly inserted elements and up to and including the last element and end iterators are invalidated.

Example
url u = parse_relative_uri( "/path/file.txt" );

segments_encoded se = u.encoded_segments();

se.insert( u.end() - 1, { "to", "the" } );

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

Behavior is undefined if any elements of the initializer_list 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 elements should be inserted.

init

The initializer list containing percent-encoded segments to insert.

Exceptions

Type

Thrown On

std::invalid_argument

invalid percent-encoding


PrevUpHomeNext