#include <bn_string.h>
template<int MaxSize>
bn::string class

std::string like container with a fixed size buffer.

Template parameters
MaxSize Maximum number of characters that can be stored.

It doesn't throw exceptions. Instead, asserts are used to ensure valid usage.

Base classes

class istring
Base class of bn::string.

Constructors, destructors, conversion operators

string()
Default constructor.
string(const string& other)
Copy constructor.
string(const istring_base& other)
Copy constructor.
string(const istring_base& other, size_type position)
Copy constructor.
string(const istring_base& other, size_type position, size_type count)
Copy constructor.
string(const string_view& view)
Copy constructor.
string(const_pointer char_array_ptr)
Copy constructor.
string(const_pointer char_array_ptr, size_type char_array_size)
Copy constructor.
string(size_type count, value_type value)
Constructs a string with count copies of character value.
string(const_iterator first, const_iterator last)
Constructs a string with the characters in the range [first, last).

Public functions

auto operator=(const string& other) -> string&
Copy assignment operator.
auto operator=(const istring_base& other) -> string&
Copy assignment operator.
auto operator=(const string_view& view) -> string&
Copy assignment operator.
auto operator=(const_pointer char_array_ptr) -> string&
Copy assignment operator.
auto substr() const -> string
Returns a copy of this.
auto substr(size_type position) const -> string
Returns the substring [position, size() - position).
auto substr(size_type position, size_type count) const -> string
Returns the substring [position, position + count).

Friends

auto operator+(const string& a, const istring_base& b) -> string
Concatenates a string and a istring_base.
auto operator+(const string& a, value_type b) -> string
Concatenates a string and a character.
auto operator+(const string& a, const string_view& b) -> string
Concatenates two strings.
auto operator+(const string& a, const_pointer b) -> string
Concatenates two strings.

Function documentation

template<int MaxSize>
bn::string<MaxSize>::string(const string& other)

Copy constructor.

Parameters
other string to copy.

template<int MaxSize>
bn::string<MaxSize>::string(const istring_base& other)

Copy constructor.

Parameters
other istring_base to copy.

template<int MaxSize>
bn::string<MaxSize>::string(const istring_base& other, size_type position)

Copy constructor.

Parameters
other istring_base to copy.
position Starting character index.

template<int MaxSize>
bn::string<MaxSize>::string(const istring_base& other, size_type position, size_type count)

Copy constructor.

Parameters
other istring_base to copy.
position Starting character index.
count Number of characters to copy.

template<int MaxSize>
bn::string<MaxSize>::string(const string_view& view)

Copy constructor.

Parameters
view string_view to copy.

template<int MaxSize>
bn::string<MaxSize>::string(const_pointer char_array_ptr)

Copy constructor.

Parameters
char_array_ptr Pointer to null-terminated characters array.

template<int MaxSize>
bn::string<MaxSize>::string(const_pointer char_array_ptr, size_type char_array_size)

Copy constructor.

Parameters
char_array_ptr Pointer to characters array.
char_array_size Characters count of the characters array.

template<int MaxSize>
bn::string<MaxSize>::string(size_type count, value_type value)

Constructs a string with count copies of character value.

Parameters
count Number of characters to assign.
value Character to assign.

template<int MaxSize>
bn::string<MaxSize>::string(const_iterator first, const_iterator last)

Constructs a string with the characters in the range [first, last).

Parameters
first First element of the range.
last Last element of the range.

template<int MaxSize>
string& bn::string<MaxSize>::operator=(const string& other)

Copy assignment operator.

Parameters
other string to copy.
Returns Reference to this.

template<int MaxSize>
string& bn::string<MaxSize>::operator=(const istring_base& other)

Copy assignment operator.

Parameters
other istring_base to copy.
Returns Reference to this.

template<int MaxSize>
string& bn::string<MaxSize>::operator=(const string_view& view)

Copy assignment operator.

Parameters
view string_view to copy.
Returns Reference to this.

template<int MaxSize>
string& bn::string<MaxSize>::operator=(const_pointer char_array_ptr)

Copy assignment operator.

Parameters
char_array_ptr Pointer to null-terminated characters array.
Returns Reference to this.

template<int MaxSize>
string operator+(const string& a, const istring_base& b)

Concatenates a string and a istring_base.

Parameters
a First string to concatenate.
b Second istring_base to concatenate.
Returns string containing characters from a followed by the characters from b.

template<int MaxSize>
string operator+(const string& a, value_type b)

Concatenates a string and a character.

Parameters
a First string to concatenate.
b Second character to concatenate.
Returns string containing characters from a followed by b.

template<int MaxSize>
string operator+(const string& a, const string_view& b)

Concatenates two strings.

Parameters
a First string to concatenate.
b Second string_view to concatenate.
Returns string containing characters from a followed by the characters from b.

template<int MaxSize>
string operator+(const string& a, const_pointer b)

Concatenates two strings.

Parameters
a First string to concatenate.
b Second pointer to null-terminated characters array to concatenate.
Returns string containing characters from a followed by the characters from b.