[#boost-urls-segments_ref]
= xref:boost.adoc[boost]::xref:boost/urls.adoc[urls]::segments&lowbar;ref
:relfileprefix: ../../
:mrdocs:


A view representing path segments in a URL

== Synopsis


Declared in `&lt;https://www.github.com/boostorg/url/blob/develop/include/boost/url/segments_ref.hpp#L85[boost&sol;url&sol;segments&lowbar;ref&period;hpp]&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class segments&lowbar;ref
    : public xref:boost/urls/segments_base.adoc[segments&lowbar;base];
----

== Types

[cols=2]
|===
| Name | Description 

| xref:boost/urls/segments_base/const_iterator.adoc[`const&lowbar;iterator`] 
| A Bidirectional iterator to a path segment

| xref:boost/urls/segments_base/const_reference.adoc[`const&lowbar;reference`] 
| The reference type

| xref:boost/urls/segments_base/difference_type.adoc[`difference&lowbar;type`] 
| A signed integer type used to represent differences&period;

| xref:boost/urls/segments_base/iterator.adoc[`iterator`] 
| A Bidirectional iterator to a path segment

| xref:boost/urls/segments_base/reference.adoc[`reference`] 
| The reference type

| xref:boost/urls/segments_base/size_type.adoc[`size&lowbar;type`] 
| An unsigned integer type used to represent size&period;

| xref:boost/urls/segments_base/value_type.adoc[`value&lowbar;type`] 
| The value type

|===
== Member Functions

[cols=2]
|===
| Name | Description 

| xref:boost/urls/segments_ref/assign.adoc[`assign`] 
| Assign segments


| xref:boost/urls/segments_base/back.adoc[`back`] 
| Return the last segment

| xref:boost/urls/segments_base/begin.adoc[`begin`] 
| Return an iterator to the beginning

| xref:boost/urls/segments_base/buffer.adoc[`buffer`] 
| Return the referenced character buffer&period;

| xref:boost/urls/segments_ref/clear.adoc[`clear`] 
| Clear the contents of the container

| xref:boost/urls/segments_base/empty.adoc[`empty`] 
| Return true if there are no segments

| xref:boost/urls/segments_base/end.adoc[`end`] 
| Return an iterator to the end

| xref:boost/urls/segments_ref/erase.adoc[`erase`] 
| Erase segments


| xref:boost/urls/segments_base/front.adoc[`front`] 
| Return the first segment

| xref:boost/urls/segments_ref/insert.adoc[`insert`] 
| Insert segments


| xref:boost/urls/segments_base/is_absolute.adoc[`is&lowbar;absolute`] 
| Returns true if this references an absolute path&period;

| xref:boost/urls/segments_ref/2conversion.adoc[`operator segments&lowbar;view`] 
| Conversion

| xref:boost/urls/segments_ref/operator_assign.adoc[`operator&equals;`] 
| Assignment


| xref:boost/urls/segments_ref/pop_back.adoc[`pop&lowbar;back`] 
| Remove the last segment

| xref:boost/urls/segments_ref/push_back.adoc[`push&lowbar;back`] 
| Append a segment

| xref:boost/urls/segments_ref/replace.adoc[`replace`] 
| Replace segments


| xref:boost/urls/segments_ref/2constructor-09.adoc[`segments&lowbar;ref`]         [.small]#[constructor]#
| Constructor

| xref:boost/urls/segments_base/size.adoc[`size`] 
| Return the number of segments

| xref:boost/urls/segments_ref/url.adoc[`url`] 
| Return the referenced url

|===
== Static Member Functions

[cols=2]
|===
| Name | Description 

| xref:boost/urls/segments_base/max_size.adoc[`max&lowbar;size`] 
| Return the maximum number of characters possible

|===



== Description


Objects of this type are used to interpret    the path as a bidirectional view of segments,    where each segment is a string with percent    escapes automatically decoded&period;

The view does not retain ownership of the    elements and instead references the original    character buffer&period; The caller is responsible    for ensuring that the lifetime of the buffer    extends until it is no longer referenced&period;

The view is modifiable&semi; calling non&hyphen;const    members causes changes to the referenced    url&period;


=== Example

[,cpp]
----
url u( "/path/to/file.txt" );

segments_ref ps = u.segments();
----
Percent escapes in strings returned when    dereferencing iterators are automatically    decoded&period;    Reserved characters in strings supplied    to modifier functions are automatically    percent&hyphen;escaped&period;


=== Iterator Invalidation

Changes to the underlying character buffer    can invalidate iterators which reference it&period;    Modifications made through the container    invalidate some or all iterators&colon; 

* push&lowbar;back
 &colon; Only 
`end()`
&period;
* assign
, 
clear
,        
operator&equals;
 &colon; All elements&period;
* erase
 &colon; Erased elements and all        elements after (including 
`end()`
)&period;
* insert
 &colon; All elements at or after        the insertion point (including 
`end()`
)&period;
* replace
 &colon; Modified        elements and all elements
        after (including 
`end()`
)&period;

A view representing path segments in a URL

Objects of this type are used to interpret    the path as a bidirectional view of segments,    where each segment is a string with percent    escapes automatically decoded&period;

The view does not retain ownership of the    elements and instead references the original    character buffer&period; The caller is responsible    for ensuring that the lifetime of the buffer    extends until it is no longer referenced&period;

The view is modifiable&semi; calling non&hyphen;const    members causes changes to the referenced    url&period;


=== Example

[,cpp]
----
url u( "/path/to/file.txt" );

segments_ref ps = u.segments();
----
Percent escapes in strings returned when    dereferencing iterators are automatically    decoded&period;    Reserved characters in strings supplied    to modifier functions are automatically    percent&hyphen;escaped&period;


=== Iterator Invalidation

Changes to the underlying character buffer    can invalidate iterators which reference it&period;    Modifications made through the container    invalidate some or all iterators&colon; 

* push&lowbar;back
 &colon; Only 
`end()`
&period;
* assign
, 
clear
,        
operator&equals;
 &colon; All elements&period;
* erase
 &colon; Erased elements and all        elements after (including 
`end()`
)&period;
* insert
 &colon; All elements at or after        the insertion point (including 
`end()`
)&period;
* replace
 &colon; Modified        elements and all elements
        after (including 
`end()`
)&period;



== See Also


xref:boost/urls/segments_encoded_ref.adoc[segments&lowbar;encoded&lowbar;ref],        xref:boost/urls/segments_encoded_view.adoc[segments&lowbar;encoded&lowbar;view],        xref:boost/urls/segments_view.adoc[segments&lowbar;view]&period;



xref:boost/urls/segments_encoded_ref.adoc[segments&lowbar;encoded&lowbar;ref],        xref:boost/urls/segments_encoded_view.adoc[segments&lowbar;encoded&lowbar;view],        xref:boost/urls/segments_view.adoc[segments&lowbar;view]&period;






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