[#boost-urls-url_base-set_path_absolute]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::xref:boost/urls/url_base.adoc[url&lowbar;base]::set&lowbar;path&lowbar;absolute
:relfileprefix: ../../../
:mrdocs:


Set if the path is absolute

== Synopsis


Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/url_base.hpp#L1699[boost&sol;url&sol;url&lowbar;base&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
bool
set&lowbar;path&lowbar;absolute(bool absolute);
----

== Description


This function adjusts the path to make        it absolute or not, depending on the        parameter&period;

[NOTE]
If an authority is present, the path        is always absolute&period; In this case, the        function has no effect&period;


=== Example

[,cpp]
----
url u( "path/to/file.txt" );
assert( u.set_path_absolute( true ) );
assert( u.buffer() == "/path/to/file.txt" );
----

=== Postconditions

[,cpp]
----
this->is_path_absolute() == true && this->encoded_path().front() == '/'
----

=== Complexity

Linear in `this&hyphen;&gt;size()`&period;


=== BNF

[,cpp]
----
path          = path-abempty    ; begins with "/" or is empty
              / path-absolute   ; begins with "/" but not "//"
              / path-noscheme   ; begins with a non-colon segment
              / path-rootless   ; begins with a segment
              / path-empty      ; zero characters

path-abempty  = *( "/" segment )
path-absolute = "/" [ segment-nz *( "/" segment ) ]
path-noscheme = segment-nz-nc *( "/" segment )
path-rootless = segment-nz *( "/" segment )
path-empty    = 0<pchar>
----

=== Specification

* link:https://datatracker.ietf.org/doc/html/rfc3986#section-3.3[3&period;3&period;  Path (rfc3986)]



== Return Value


true on success&period;



== See Also


xref:boost/urls/url_base/encoded_segments-0e5.adoc[encoded&lowbar;segments],            xref:boost/urls/url_base/segments-04.adoc[segments],            xref:boost/urls/url_base/set_encoded_path.adoc[set&lowbar;encoded&lowbar;path],            xref:boost/urls/url_base/set_path.adoc[set&lowbar;path]&period;






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