Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the master branch, built from commit 5002c2d6a2.


The fragment provides a refinement of the resource specification usually interpreted as a single string. It provides directions to a secondary resource related to such main resource, such as the section in an article or a time-point in a video.

As usual, its semantics vary depending on the scheme, authority, path, and media type of the resource. In HTML, fragments are used as internal page references. This usage is called a "named anchor," referring to a section within a web page. The URL below points to the anchor "section2":

url_view u("");
assert(u.fragment() == "section2");

These functions do not throw. The URL fragment might also be empty or absent. If the URL has no fragment, these functions return an empty string. The function has_fragment can be used to determine whether this empty string means there is no fragment or an empty fragment string in the URL.


The URL reserved characters :, @, ?, and / may appear unencoded with URL fragments, as they are not ambiguous with other URL components.

url_view u("");
assert(u.fragment() == "code :a@b?c/d");