[#BloombergLP-bslstl-StringRefImp-0c]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bslstl.adoc[bslstl]::StringRefImp
:relfileprefix: ../../
:mrdocs:

Provide a non&hyphen;owning reference to a contiguous character sequence&period;

== Synopsis

Declared in `&lt;bslstl&lowbar;stringref&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;class CHAR&lowbar;TYPE&gt;
class StringRefImp
    : public xref:BloombergLP/bslstl/StringRefData-04.adoc[StringRefData&lt;CHAR&lowbar;TYPE&gt;]
----

== Description

This class provides a reference&hyphen;semantic&hyphen;like (see below) mechanism that allows `const` `std&colon;&colon;string` values, which are represented externally as either an `std&colon;&colon;string` or null&hyphen;terminated c&hyphen;style string (or parts thereof), to be treated both uniformly and efficiently when passed as an argument to a function in which the string&apos;s length will be needed&period; The interface of this class provides a subset of accessor methods found on `std&colon;&colon;string` (but none of the manipulators) &hyphen;&hyphen; all of which apply to the referenced string&period; But, because only non&hyphen;modifiable access is afforded to the referenced string value, each of the manipulators on this type &hyphen;&hyphen; assignment in particular &hyphen;&hyphen; apply to this string&hyphen;reference object itself (as if it had pointer semantics)&period; Hence, this class has a hybrid of reference&hyphen; and pointer&hyphen;semantics&period;

This class&colon; &ast; supports a complete set of _value&hyphen;semantic_ operations

* except for `bdex` serialization &ast; is _exception&hyphen;neutral_ (agnostic) &ast; is _alias&hyphen;safe_ &ast; is `const` _thread&hyphen;safe_ For terminology see `bsldoc&lowbar;glossary`&period;

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bslstl/StringRefData-04.adoc[StringRefData&lt;CHAR&lowbar;TYPE&gt;]`
| This class is an intermediate link between `bslstl&colon;&colon;StringRef` used in BDE and `bsl&colon;&colon;string&lowbar;view` and is kept only for compatibility with legacy code&period;
|===

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/StringRefImp-0c/const_iterator.adoc[`const&lowbar;iterator`] 
| Alias for a constant iterator over the characters of this ref&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/const_reference.adoc[`const&lowbar;reference`] 
| This `typedef` is an alias to `reference`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/const_reverse_iterator.adoc[`const&lowbar;reverse&lowbar;iterator`] 
| This `typedef` is an alias to `bsl&colon;&colon;reverse&lowbar;iterator&lt;const&lowbar;iterator&gt;`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/difference_type.adoc[`difference&lowbar;type`] 
| This `typedef` is an alias to `std&colon;&colon;ptrdiff&lowbar;t`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/iterator.adoc[`iterator`] 
| This `typedef` is an alias to `value&lowbar;type const &ast;`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/reference.adoc[`reference`] 
| This `typedef` is an alias to `value&lowbar;type const&amp;`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/size_type.adoc[`size&lowbar;type`] 
| Standard Library general container requirements&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/value_type.adoc[`value&lowbar;type`] 
| Alias for a constant character type stored in this string ref&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/StringRefImp-0c/2constructor-07.adoc[`StringRefImp`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bslstl/StringRefImp-0c/assign-0d.adoc[`assign`] 
| `assign` overloads
| xref:BloombergLP/bslstl/StringRefImp-0c/begin.adoc[`begin`] 
| Return an iterator to the first character of the referenced string&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/compare.adoc[`compare`] 
| Lexicographically compare this string with `other`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/data.adoc[`data`] 
| Return a pointer to the first character of the referenced string&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/empty.adoc[`empty`] 
| Return `true` if this string reference is empty&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/end.adoc[`end`] 
| Return an iterator past the last character of the referenced string&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/isEmpty.adoc[`isEmpty`] 
| Return `true` if this object represents an empty string value, and `false` otherwise&period; This object represents an empty string value if `begin() &equals;&equals; end()`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/length.adoc[`length`] 
| Return the length of the string referred to by this object&period; Note that this call is equivalent to `end() &hyphen; begin()`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/operator_subs.adoc[`operator&lsqb;&rsqb;`] 
| Return a reference to the character at the specified `index`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/rbegin.adoc[`rbegin`] 
| Return a reverse iterator to the last character of the string&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/rend.adoc[`rend`] 
| Return a reverse iterator before the first character of the string&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/reset.adoc[`reset`] 
| Reset this string reference to the empty default&hyphen;constructed state&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/size.adoc[`size`] 
| Return the number of characters in the string referred to by this object&period; Note that this call is equivalent to `end() &hyphen; begin()`&period;
| xref:BloombergLP/bslstl/StringRefData-04/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;StringRefData, is&lowbar;trivially&lowbar;copyable&gt;`] 
| Nested trait declaration for `bsl&colon;&colon;is&lowbar;trivially&lowbar;copyable`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/2conversion-09.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;StringRefImp, is&lowbar;trivially&lowbar;copyable&gt;`] 
| Nested trait declaration for `bsl&colon;&colon;is&lowbar;trivially&lowbar;copyable`&period;
| xref:BloombergLP/bslstl/StringRefImp-0c/2conversion-0d.adoc[`operator std::basic&lowbar;string&lt;CHAR&lowbar;TYPE&gt;`] 
| Return an `std&colon;&colon;basic&lowbar;string` (synonymous with `std&colon;&colon;basic&lowbar;string`) having the value of the string bound to this string reference&period;
|===


== Static Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/StringRefData-04/cStringLength.adoc[`cStringLength`] 
| Return the number of `CHAR&lowbar;TYPE` characters in the specified null&hyphen;terminated `data` string, up to but not including the terminal null value&period;
|===


== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bslstl/operator_plus-00.adoc[`operator&plus;`]
| Return the concatenation of the specified `lhs` string ref and the specified `rhs` `std&colon;&colon;basic&lowbar;string` value&period;
| xref:BloombergLP/bslstl/operator_plus-02.adoc[`operator&plus;`]
| Return a `bsl&colon;&colon;string` having the value of the concatenation of the strings referred to by the specified `lhs` and `rhs` values&period;
| xref:BloombergLP/bslstl/operator_plus-05.adoc[`operator&plus;`]
| Return the concatenation of the specified `lhs` string ref and the specified `rhs` `bsl&colon;&colon;basic&lowbar;string` value&period;
| xref:BloombergLP/bslstl/operator_plus-076.adoc[`operator&plus;`]
| Return the concatenation of the specified string ref and C string&period;
|===

== Template Parameters

[cols="1,4"]
|===
| Name| Description
| *CHAR&lowbar;TYPE*
| character type of the referenced character sequence&period;
|===


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