Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext
url::set_port

Set the port.

Synopsis
url&
set_port(
    core::string_view s);
Description

This port is set to the string, which must contain only digits or be empty. An empty port string is distinct from having no port.

Example
assert( [link url.ref.boost__urls__url.url `url`]( "http://www.example.com" ).[link url.ref.boost__urls__url.set_port `set_port`]( "8080" ).[link url.ref.boost__urls__url.authority `authority`]().[link url.ref.boost__urls__url.buffer `buffer`]() == "www.example.com:8080" );
Postconditions
this->[link url.ref.boost__urls__url.has_port `has_port`]() == true && this->[link url.ref.boost__urls__url.port_number `port_number`]() == n && this->[link url.ref.boost__urls__url.port `port`]() == std::to_string(n)
Exception Safety

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

Exceptions

Type

Thrown On

system_error

s does not contain a valid port.

Parameters

Name

Description

s

The port string to set.

BNF
[link url.ref.boost__urls__url.port `port`]          = *DIGIT
Specification
See Also

remove_port, /root/project/libs/url/include/boost/url/url.hpp


PrevUpHomeNext