[#boost-urls-ipv6_address-to_string]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/ipv6_address.adoc[ipv6&lowbar;address]::to&lowbar;string
:relfileprefix: ../../../
:mrdocs:

Return the address as a string&period;

== Synopsis

Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/ipv6_address.hpp#L224[boost&sol;url&sol;ipv6&lowbar;address&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;xref:boost/urls/string_token/StringToken.adoc[string&lowbar;token::StringToken] StringToken = xref:boost/urls/string_token/return_string.adoc[string&lowbar;token::return&lowbar;string]&gt;
StringToken::result&lowbar;type
to&lowbar;string(StringToken&& token);
----

== Description

The returned string does not contain surrounding square brackets&period;

When called with no arguments, the return type is `std&colon;&colon;string`&period; Otherwise, the return type and style of output is determined by which string token is passed&period;

== Example
[,cpp]
----
ipv6_address::bytes_type b = {{
        0, 1, 0, 2, 0, 3, 0, 4,
        0, 5, 0, 6, 0, 7, 0, 8 }};
ipv6_address a(b);
assert(a.to_string() == "1:2:3:4:5:6:7:8");
assert( ipv4_address(0x01020304).to_string() == "1.2.3.4" );
----
== Complexity
Constant&period;

== Exception Safety
Strong guarantee&period; Calls to allocate may throw&period; String tokens may throw exceptions&period;

== Specification
* https://datatracker.ietf.org/doc/html/rfc4291#section-2.2[]

== Return Value

The return type of the string token&period; If the token parameter is omitted, then a new `std&colon;&colon;string` is returned&period; Otherwise, the function return type is the result type of the token&period;

== Parameters

[cols=2]
|===
| Name
| Description
| *token*
| An optional string token&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
