Public Member Functions | Static Public Attributes | List of all members
TemporaryString Class Reference

TemporaryString. More...

#include <TemporaryString.hh>

Public Member Functions

template<typename FillOp >
 TemporaryString (size_t n_, FillOp op)
 TemporaryString (const TemporaryString &)=delete
 TemporaryString (TemporaryString &&)=delete
TemporaryStringoperator= (const TemporaryString &)=delete
TemporaryStringoperator= (TemporaryString &&)=delete
char * data ()
const char * c_str () const
 operator std::string_view () const
 operator zstring_view () const

Static Public Attributes

static constexpr size_t BUFSIZE = 127

Detailed Description


This a type meant to store temporary strings. Typically it stores the string in the object itself. Except when the string is too large, then it falls back to heap-allocation. So it's more or less like a std::string but with a relatively large (127 character) "small-string-buffer". (Typical std::string implementations only have a buffer for 15 or 23 characters).

Because of this internal buffer, TemporaryString objects are quite large. The intention is that they are only used as local variable (so stored on the stack). Not as member variables.

The API of this type is still very minimal. It can be extended when needed.

Definition at line 23 of file TemporaryString.hh.

Constructor & Destructor Documentation

◆ TemporaryString() [1/3]

template<typename FillOp >
TemporaryString::TemporaryString ( size_t  n_,
FillOp  op 

Definition at line 28 of file TemporaryString.hh.

References allocate_string_storage(), and BUFSIZE.

◆ TemporaryString() [2/3]

TemporaryString::TemporaryString ( const TemporaryString )

◆ TemporaryString() [3/3]

TemporaryString::TemporaryString ( TemporaryString &&  )

Member Function Documentation

◆ c_str()

const char* TemporaryString::c_str ( ) const

Definition at line 46 of file TemporaryString.hh.

◆ data()

char* TemporaryString::data ( )

Definition at line 45 of file TemporaryString.hh.

◆ operator std::string_view()

TemporaryString::operator std::string_view ( ) const

Definition at line 48 of file TemporaryString.hh.

◆ operator zstring_view()

TemporaryString::operator zstring_view ( ) const

Definition at line 49 of file TemporaryString.hh.

◆ operator=() [1/2]

TemporaryString& TemporaryString::operator= ( const TemporaryString )

◆ operator=() [2/2]

TemporaryString& TemporaryString::operator= ( TemporaryString &&  )

Member Data Documentation


constexpr size_t TemporaryString::BUFSIZE = 127

Definition at line 25 of file TemporaryString.hh.

Referenced by TemporaryString().

The documentation for this class was generated from the following file: