Pigweed
 
Loading...
Searching...
No Matches
pw::InlineBasicString< T, kCapacity > Class Template Referencefinal

pw::InlineBasicString is a fixed-capacity version of std::basic_string. In brief: More...

#include <string.h>

Public Member Functions

constexpr InlineBasicString (size_t count, T ch)
 
template<size_t kOtherCapacity>
constexpr InlineBasicString (const InlineBasicString< T, kOtherCapacity > &other, size_t index, size_t count=npos)
 
constexpr InlineBasicString (const T *string, size_t count)
 
template<typename U , typename = string_impl::EnableIfNonArrayCharPointer<T, U>>
constexpr InlineBasicString (U c_string)
 
template<size_t kCharArraySize>
constexpr InlineBasicString (const T(&array)[kCharArraySize])
 
template<typename InputIterator , typename = string_impl::EnableIfInputIterator<InputIterator>>
constexpr InlineBasicString (InputIterator start, InputIterator finish)
 
constexpr InlineBasicString (const InlineBasicString &)=default
 
template<size_t kOtherCapacity>
constexpr InlineBasicString (const InlineBasicString< T, kOtherCapacity > &other)
 
constexpr InlineBasicString (std::initializer_list< T > list)
 
template<typename StringViewLike , string_impl::EnableIfStringViewLikeButNotStringView< T, StringViewLike > * = nullptr>
constexpr InlineBasicString (const StringViewLike &string)
 
template<typename StringView , std::enable_if_t< std::is_same< StringView, string_impl::View< T > >::value > * = nullptr>
constexpr InlineBasicString (const StringView &view)
 
template<typename StringView , typename = string_impl::EnableIfStringViewLike<T, StringView>>
constexpr InlineBasicString (const StringView &string, size_t index, size_t count)
 
 InlineBasicString (std::nullptr_t)=delete
 
constexpr InlineBasicStringoperator= (const InlineBasicString &other)=default
 
template<size_t kOtherCapacity>
constexpr InlineBasicStringoperator= (const InlineBasicString< T, kOtherCapacity > &other)
 
template<size_t kCharArraySize>
constexpr InlineBasicStringoperator= (const T(&array)[kCharArraySize])
 
template<typename U , typename = string_impl::EnableIfNonArrayCharPointer<T, U>>
constexpr InlineBasicStringoperator= (U c_string)
 
constexpr InlineBasicStringoperator= (T ch)
 
constexpr InlineBasicStringoperator= (std::initializer_list< T > list)
 
template<typename StringView , typename = string_impl::EnableIfStringViewLike<T, StringView>>
constexpr InlineBasicStringoperator= (const StringView &string)
 
constexpr InlineBasicStringoperator= (std::nullptr_t)=delete
 
template<size_t kOtherCapacity>
constexpr InlineBasicStringoperator+= (const InlineBasicString< T, kOtherCapacity > &string)
 
constexpr InlineBasicStringoperator+= (T character)
 
template<size_t kCharArraySize>
constexpr InlineBasicStringoperator+= (const T(&array)[kCharArraySize])
 
template<typename U , typename = string_impl::EnableIfNonArrayCharPointer<T, U>>
constexpr InlineBasicStringoperator+= (U c_string)
 
constexpr InlineBasicStringoperator+= (std::initializer_list< T > list)
 
template<typename StringView , typename = string_impl::EnableIfStringViewLike<T, StringView>>
constexpr InlineBasicStringoperator+= (const StringView &string)
 
constexpr pointer data ()
 
constexpr const_pointer data () const
 
constexpr size_t max_size () const noexcept
 

Detailed Description

template<typename T, size_t kCapacity = string_impl::kGeneric>
class pw::InlineBasicString< T, kCapacity >

pw::InlineBasicString is a fixed-capacity version of std::basic_string. In brief:

  • It is always null-terminated.
  • It stores the string contents inline and uses no dynamic memory.
  • It implements mostly the same API as std::basic_string, but the capacity of the string is fixed at construction and cannot grow. Attempting to increase the size beyond the capacity triggers an assert.

pw::InlineBasicString is efficient and compact. The current size and capacity are stored in a single word. Accessing its contents is a simple array access within the object, with no pointer indirection, even when working from a generic reference pw::InlineBasicString<T> where the capacity is not specified as a template argument. A string object can be used safely without the need to know its capacity.

See also pw::InlineString, which is an alias of pw::InlineBasicString<char> and is equivalent to std::string.


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