[#bsl-StringBufContainer]
= xref:bsl.adoc[bsl]::StringBufContainer
:relfileprefix: ../
:mrdocs:

Trivial holder of a `basic&lowbar;stringbuf` for use as a private base&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    class CHAR&lowbar;TYPE,
    class CHAR&lowbar;TRAITS,
    class ALLOCATOR&gt;
class StringBufContainer;
----

== Description

This class enables the implementation of string&hyphen;stream types by providing a trivial type containing a `basic&lowbar;stringbuf` that is suitable as a (`private`) base class for a string&hyphen;stream&period; Inheriting from `StringBufContainer` allows the string&hyphen;stream to ensure that the contained `basic&lowbar;stringbuf` is initialized before initializing other base classes or data members without potentially overriding `virtual` methods in the `basic&lowbar;stringbuf` type&period; Note that implementations of string&hyphen;stream types must pass the address of a string&hyphen;buffer to their `public` base class (e&period;g&period;, `basic&lowbar;stream`), so the string&hyphen;stream must ensure (using `private` inheritance) that the string&hyphen;buffer is initialized before constructing the `public` base class&period; If a string&hyphen;stream implementation were to directly inherit from `basic&lowbar;streambuf`, then `virtual` methods defined in that string&hyphen;stream (e&period;g&period;, `underflow`) might incorrectly override those in the `basic&lowbar;stringbuf` implementation&period;

== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:bsl/StringBufContainer/2constructor-0f.adoc[`StringBufContainer`]         [.small]#[constructor]#
| Constructors
| xref:bsl/StringBufContainer/operator_assign.adoc[`operator&equals;`] 
| Move&hyphen;assign from the specified `rhs`&period;
| xref:bsl/StringBufContainer/rdbuf.adoc[`rdbuf`] 
| Return an address providing modifiable access to the contained `basic&lowbar;stringbuf` object&period;
| xref:bsl/StringBufContainer/swap.adoc[`swap`] 
| Efficiently exchange the value of this object with `other`&period;
|===



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