BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
bio::ranges::small_string< capacity_ > Class Template Reference

Implements a small string that can be used for compile time computations. More...

#include <bio/ranges/container/small_string.hpp>

+ Inheritance diagram for bio::ranges::small_string< capacity_ >:

Public Types

Associated types
using value_type = char
 The value_type type.
 
using reference = value_type &
 The reference type.
 
using const_reference = value_type const &
 The const_reference type.
 
using iterator = value_type *
 The iterator type.
 
using const_iterator = value_type const *
 The const_iterator type.
 
using difference_type = ptrdiff_t
 The difference_type type.
 
using size_type = meta::detail::min_viable_uint_t< capacity_ >
 The size_type type.
 

Public Member Functions

Constructors, destructor and assignment
template<size_t N>
constexpr small_string (char const (&_lit)[N]) noexcept
 Construction from literal.
 
template<size_t N>
constexpr small_stringoperator= (char const (&_lit)[N]) noexcept
 Assign from literal.
 
template<size_t N>
constexpr void assign (char const (&_lit)[N]) noexcept
 Assign from literal.
 
template<std::forward_iterator begin_it_type, typename end_it_type >
requires (std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>)
constexpr void assign (begin_it_type begin_it, end_it_type end_it) noexcept
 Assign from pair of iterators.
 
Modifiers
constexpr void clear () noexcept
 Removes all elements from the container.
 
constexpr void push_back (char const value) noexcept
 Appends the given element value to the end of the container.
 
constexpr void pop_back () noexcept
 Removes the last element of the container.
 
constexpr void resize (size_type const count) noexcept
 Resizes the container to contain count elements.
 
constexpr void resize (size_type const count, char const value) noexcept
 Resizes the container to contain count elements.
 
constexpr small_stringerase (size_type index=0, size_type count=max_size()) noexcept
 Removes specified elements from the container.
 
Conversion
std::string str () const
 Returns the content represented as std::string.
 
constexpr std::string_view view () const
 Returns the content represented as std::string_view.
 
constexpr char const * c_str () const noexcept
 Returns the content represented as 0-terminated c-style string.
 
constexpr operator std::string_view () const
 Implicit conversion to std::string_view (same as calling bio::ranges::small_string::view() ).
 
Constructors, destructor and assignment
constexpr void assign (std::initializer_list< value_type > ilist) noexcept(is_noexcept)
 Assign from std::initializer_list.
 
constexpr void assign (size_type const count, value_type const value) noexcept(is_noexcept)
 Assign with count times value.
 
constexpr void assign (other_range_t &&range) noexcept(is_noexcept)
 Assign from a different range.
 
Iterators
constexpr iterator begin () noexcept
 Returns the begin iterator of the vector.
 
constexpr const_iterator begin () const noexcept
 Returns the begin iterator of the vector.
 
constexpr const_iterator cbegin () const noexcept
 Returns the begin iterator of the vector.
 
constexpr iterator end () noexcept
 Returns iterator past the end of the vector.
 
constexpr const_iterator end () const noexcept
 Returns iterator past the end of the vector.
 
constexpr const_iterator cend () const noexcept
 Returns iterator past the end of the vector.
 
Element access
reference at (size_type const i)
 Return the i-th element.
 
const_reference at (size_type const i) const
 Return the i-th element.
 
constexpr reference operator[] (size_type const i) noexcept
 Return the i-th element.
 
constexpr const_reference operator[] (size_type const i) const noexcept
 Return the i-th element.
 
constexpr reference front () noexcept
 Return the first element. Calling front on an empty container is undefined.
 
constexpr const_reference front () const noexcept
 Return the first element. Calling front on an empty container is undefined.
 
constexpr reference back () noexcept
 Return the last element.
 
constexpr const_reference back () const noexcept
 Return the last element.
 
constexpr value_typedata () noexcept
 Direct access to the underlying array.
 
constexpr value_type const * data () const noexcept
 Direct access to the underlying array.
 
Capacity
constexpr bool empty () const noexcept
 Checks whether the container is empty.
 
constexpr size_type size () const noexcept
 Returns the number of elements in the container, i.e. std::distance(begin(), end()).
 
constexpr size_type max_size () const noexcept
 Returns the maximum number of elements the container is able to hold and resolves to capacity_.
 
constexpr size_type capacity () const noexcept
 Returns the number of elements that the container is able to hold and resolves to capacity_.
 
constexpr void reserve (size_type) const noexcept
 Since the capacity is fixed on compile time, this is a no-op.
 
constexpr void shrink_to_fit () const noexcept
 Since the capacity is fixed on compile time, this is a no-op.
 
Modifiers
constexpr iterator insert (const_iterator pos, value_type const value) noexcept(is_noexcept)
 Inserts value before position in the container.
 
constexpr iterator insert (const_iterator pos, size_type const count, value_type const value) noexcept(is_noexcept)
 Inserts count copies of value before position in the container.
 
constexpr iterator insert (const_iterator pos, begin_it_type begin_it, end_it_type end_it) noexcept(is_noexcept)
 Inserts elements from range [begin_it, end_it) before position in the container.
 
constexpr iterator insert (const_iterator pos, std::initializer_list< value_type > const &ilist) noexcept(is_noexcept)
 Inserts elements from initializer list before position in the container.
 
constexpr iterator erase (const_iterator begin_it, const_iterator end_it) noexcept
 Removes specified elements from the container.
 
constexpr iterator erase (const_iterator pos) noexcept
 Removes specified elements from the container.
 
constexpr void swap (small_vector &rhs) noexcept(is_noexcept)
 Swap contents with another instance.
 
constexpr void swap (small_vector &&rhs) noexcept(is_noexcept)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 

Static Public Member Functions

Capacity
static constexpr size_type max_size () noexcept
 Returns the maximal size which equals the capacity.
 
static constexpr size_type capacity () noexcept
 Returns the maximal capacity.
 

Friends

Concatenation
template<size_t capacity2>
constexpr friend small_string< capacity_+capacity2 > operator+ (small_string const &lhs, small_string< capacity2 > const &rhs) noexcept
 Concatenates two small_strings by returning a new small_string.
 
Comparison operators

Performs element-wise comparison.

template<size_t cap2>
constexpr bool operator== (small_string const &lhs, small_string< cap2 > const &rhs) noexcept
 Performs element-wise comparison.
 
template<size_t cap2>
constexpr auto operator<=> (small_string const &lhs, small_string< cap2 > const &rhs) noexcept
 Performs element-wise comparison.
 
constexpr bool operator== (small_string const &lhs, std::string_view const &rhs) noexcept
 Performs element-wise comparison.
 
constexpr auto operator<=> (small_string const &lhs, std::string_view const &rhs) noexcept
 Performs element-wise comparison.
 
Input/output
std::ostreamoperator<< (std::ostream &os, small_string const &str)
 Formatted output for the bio::ranges::small_string.
 

Related Functions

(Note that these are not member functions.)

Deduction guides
template<size_t N>
 small_string (char const(&)[N]) -> small_string< N - 1 >
 Deduces small_string from string literals.
 
template<size_t N>
 small_string (std::array< char, N > const &) -> small_string< N >
 Deduces small_string from std::array of type char.
 
template<std::same_as< char >... t>
 small_string (t const ... chars) -> small_string< sizeof...(chars)>
 Deduces small_string from char.
 

Detailed Description

template<size_t capacity_>
class bio::ranges::small_string< capacity_ >

Implements a small string that can be used for compile time computations.

Template Parameters
capacity_The capacity of the small string.

This class provides a string type for small strings and compile-time contexts. It has fixed capacity, but variable size within the capacity. It is always allocated on the stack and most of it's members are constexpr-qualified. The underlying data can be exposed as a null-terminated c-style string (without copying) and conversion operators to std::string are provided (this involves copying).

Strings with capacity 30 or less are also marked as satisfying the std::ranges::view concept, because they can still be copied efficiently.

Implementation notes

Internally the string stores a null-terminated array of size capacity_ + 1 and the size of the string as a member. The smallest possible type is used for storage of the size. For example, small_string<30> uses 32bytes of memory (one byte extra for the null-terminator and one byte to save the size).

Example

int main()
{
constexpr bio::ranges::small_string sm{"hello"}; // construct from string literal at compile time!
static_assert(sm[0] == 'h'); // This way I can also test it at compile-time
fmt::print("{}\n", sm.size()); // prints 5! (the null character is only stored internally)
// conversion to a normal string:
std::string sm_string{sm.str()};
// access data directly with a pointer to the underlying zero-terminated array:
char const * sm_cstr{sm.c_str()};
fmt::print("{}{}{}\n", sm, sm_string, sm_cstr); // prints "hellohellohello"
}
T c_str(T... args)
Implements a small string that can be used for compile time computations.
Definition: small_string.hpp:47
Core alphabet concept and free function/type trait wrappers.
A constexpr string implementation to manipulate string literals at compile time.

Constructor & Destructor Documentation

◆ small_string()

template<size_t capacity_>
template<size_t N>
constexpr bio::ranges::small_string< capacity_ >::small_string ( char const (&)  _lit[N])
inlineconstexprnoexcept

Construction from literal.

Parameters
_litThe literal to construct the string for.

The char literal is expected to be null-terminated (asserted in debug-mode). If it is not, the last character will be lost when copying to the instance of small_string.

Exceptions

No-throw guarantee.

Member Function Documentation

◆ assign() [1/5]

template<size_t capacity_>
template<std::forward_iterator begin_it_type, typename end_it_type >
requires (std::sentinel_for<end_it_type, begin_it_type> && std::constructible_from<value_type, std::iter_reference_t<begin_it_type>>)
constexpr void bio::ranges::small_string< capacity_ >::assign ( begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexcept

Assign from pair of iterators.

Template Parameters
begin_it_typeMust satisfy std::forward_iterator and the value_type must be constructible from the reference type of begin_it_type.
end_it_typeMust satisfy std::sentinel_for.
Parameters
[in]begin_itBegin of range to construct/assign from.
[in]end_itEnd of range to construct/assign from.

Complexity

Linear in the distance between begin_it and end_it.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

◆ assign() [2/5]

template<size_t capacity_>
template<size_t N>
constexpr void bio::ranges::small_string< capacity_ >::assign ( char const (&)  _lit[N])
inlineconstexprnoexcept

Assign from literal.

Parameters
_litThe literal to assign the string from.

The char literal is expected to be null-terminated (asserted in debug-mode). If it is not, the last character will be lost when copying to the instance of small_string.

Complexity

Linear in the size of _lit.

Exceptions

No-throw guarantee.

◆ assign() [3/5]

constexpr void bio::ranges::small_vector< char , capacity_ >::assign ( other_range_t &&  range)
inlineconstexprnoexceptinherited

Assign from a different range.

Template Parameters
other_range_tThe type of range to be inserted; must satisfy std::ranges::input_range and value_type must be constructible from std::ranges::range_reference_t<other_range_t>.
Parameters
[in]rangeThe sequences to construct/assign from.

Complexity

Linear in the size of range.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

◆ assign() [4/5]

constexpr void bio::ranges::small_vector< char , capacity_ >::assign ( size_type const  count,
value_type const  value 
)
inlineconstexprnoexceptinherited

Assign with count times value.

Parameters
[in]countNumber of elements.
[in]valueThe initial value to be assigned.

Complexity

In $O(count)$.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

◆ assign() [5/5]

constexpr void bio::ranges::small_vector< char , capacity_ >::assign ( std::initializer_list< value_type ilist)
inlineconstexprnoexceptinherited

Assign from std::initializer_list.

Parameters
[in]ilistA std::initializer_list of value_type.

Complexity

Linear in the size of ilist.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

◆ at() [1/2]

reference bio::ranges::small_vector< char , capacity_ >::at ( size_type const  i)
inlineinherited

Return the i-th element.

Parameters
[in]iIndex of the element to retrieve.
Exceptions
std::out_of_rangeIf you access an element behind the last.
Returns
A reference to the value at position i.
Attention
This is the only function of this class that is not constexpr because it might throw.

Complexity

Constant.

Exceptions

Throws std::out_of_range if i >= size().

◆ at() [2/2]

const_reference bio::ranges::small_vector< char , capacity_ >::at ( size_type const  i) const
inlineinherited

Return the i-th element.

Parameters
[in]iIndex of the element to retrieve.
Exceptions
std::out_of_rangeIf you access an element behind the last.
Returns
A reference to the value at position i.
Attention
This is the only function of this class that is not constexpr because it might throw.

Complexity

Constant.

Exceptions

Throws std::out_of_range if i >= size().

◆ back() [1/2]

constexpr const_reference bio::ranges::small_vector< char , capacity_ >::back ( ) const
inlineconstexprnoexceptinherited

Return the last element.

Returns
A reference to the value at the last position.

Calling back on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ back() [2/2]

constexpr reference bio::ranges::small_vector< char , capacity_ >::back ( )
inlineconstexprnoexceptinherited

Return the last element.

Returns
A reference to the value at the last position.

Calling back on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ begin()

constexpr const_iterator bio::ranges::small_vector< char , capacity_ >::begin ( ) const
inlineconstexprnoexceptinherited

Returns the begin iterator of the vector.

◆ c_str()

template<size_t capacity_>
constexpr char const * bio::ranges::small_string< capacity_ >::c_str ( ) const
inlineconstexprnoexcept

Returns the content represented as 0-terminated c-style string.

Returns
char const * The stored string.

Exceptions

No-throw guarantee.

Complexity

Constant.

◆ capacity()

constexpr size_type bio::ranges::small_vector< char , capacity_ >::capacity ( ) const
inlineconstexprnoexceptinherited

Returns the number of elements that the container is able to hold and resolves to capacity_.

Returns
The capacity of the currently allocated storage.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ cbegin()

constexpr const_iterator bio::ranges::small_vector< char , capacity_ >::cbegin ( ) const
inlineconstexprnoexceptinherited

Returns the begin iterator of the vector.

◆ cend()

constexpr const_iterator bio::ranges::small_vector< char , capacity_ >::cend ( ) const
inlineconstexprnoexceptinherited

Returns iterator past the end of the vector.

◆ clear()

template<size_t capacity_>
constexpr void bio::ranges::small_string< capacity_ >::clear ( )
inlineconstexprnoexcept

Removes all elements from the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ data()

constexpr value_type const * bio::ranges::small_vector< char , capacity_ >::data ( ) const
inlineconstexprnoexceptinherited

Direct access to the underlying array.

◆ empty()

constexpr bool bio::ranges::small_vector< char , capacity_ >::empty ( ) const
inlineconstexprnoexceptinherited

Checks whether the container is empty.

Returns
true if the container is empty, false otherwise.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ end()

constexpr const_iterator bio::ranges::small_vector< char , capacity_ >::end ( ) const
inlineconstexprnoexceptinherited

Returns iterator past the end of the vector.

◆ erase() [1/3]

constexpr iterator bio::ranges::small_vector< char , capacity_ >::erase ( const_iterator  begin_it,
const_iterator  end_it 
)
inlineconstexprnoexceptinherited

Removes specified elements from the container.

Parameters
begin_itBegin of range to erase.
end_itBehind the end of range to erase.
Returns
Iterator following the last element removed. If the iterator pos refers to the last element, the end() iterator is returned.

Invalidates iterators and references at or after the point of the erase, including the end() iterator.

The iterator begin_it does not need to be dereferenceable if begin_it==end_it: erasing an empty range is a no-op.

Complexity

Linear in size().

Exceptions

No-throw guarantee.

◆ erase() [2/3]

constexpr iterator bio::ranges::small_vector< char , capacity_ >::erase ( const_iterator  pos)
inlineconstexprnoexceptinherited

Removes specified elements from the container.

Parameters
posRemove the element at pos.
Returns
Iterator following the last element removed. If the iterator pos refers to the last element, the end() iterator is returned.

Invalidates iterators and references at or after the point of the erase, including the end() iterator.

The iterator pos must be valid and dereferenceable. Thus the end() iterator (which is valid, but is not dereferencable) cannot be used as a value for pos.

Complexity

Linear in size().

Exceptions

No-throw guarantee.

◆ erase() [3/3]

template<size_t capacity_>
constexpr small_string & bio::ranges::small_string< capacity_ >::erase ( size_type  index = 0,
size_type  count = max_size() 
)
inlineconstexprnoexcept

Removes specified elements from the container.

Parameters
indexRemove the elements starting at index. Defaults to 0.
countThe number of elements to remove. Defaults to max_size().
Returns
*this

Invalidates iterators and references at or after the point of the erase, including the end() iterator.

The iterator pos must be valid and dereferenceable. Thus the end() iterator (which is valid, but is not dereferencable) cannot be used as a value for pos.

Complexity

Linear in size().

Exceptions

No-throw guarantee.

◆ front() [1/2]

constexpr const_reference bio::ranges::small_vector< char , capacity_ >::front ( ) const
inlineconstexprnoexceptinherited

Return the first element. Calling front on an empty container is undefined.

Returns
A reference to the value at the first position.

Calling front on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ front() [2/2]

constexpr reference bio::ranges::small_vector< char , capacity_ >::front ( )
inlineconstexprnoexceptinherited

Return the first element. Calling front on an empty container is undefined.

Returns
A reference to the value at the first position.

Calling front on an empty container is undefined. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ insert() [1/4]

constexpr iterator bio::ranges::small_vector< char , capacity_ >::insert ( const_iterator  pos,
begin_it_type  begin_it,
end_it_type  end_it 
)
inlineconstexprnoexceptinherited

Inserts elements from range [begin_it, end_it) before position in the container.

Template Parameters
begin_it_typeMust satisfy std::forward_iterator and the value_type must be constructible from the reference type of begin_it_type.
end_it_typeMust satisfy std::sentinel_for.
Parameters
[in]posIterator before which the content will be inserted. pos may be the end() iterator.
[in]begin_itBegin of range to construct/assign from.
[in]end_itEnd of range to construct/assign from.
Returns
Iterator pointing to the first element inserted, or pos if begin_it==end_it.

The behaviour is undefined if begin_it and end_it are iterators into *this or if, given the size n of the range represented by [begin_t, end_it), size() + n > capacity().

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

◆ insert() [2/4]

constexpr iterator bio::ranges::small_vector< char , capacity_ >::insert ( const_iterator  pos,
size_type const  count,
value_type const  value 
)
inlineconstexprnoexceptinherited

Inserts count copies of value before position in the container.

Parameters
posIterator before which the content will be inserted. pos may be the end() iterator.
countNumber of copies.
valueElement value to insert.
Returns
Iterator pointing to the first element inserted, or pos if count==0.

If size() + count > capacity() this function results in undefined behaviour.

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

◆ insert() [3/4]

constexpr iterator bio::ranges::small_vector< char , capacity_ >::insert ( const_iterator  pos,
std::initializer_list< value_type > const &  ilist 
)
inlineconstexprnoexceptinherited

Inserts elements from initializer list before position in the container.

Parameters
posIterator before which the content will be inserted. pos may be the end() iterator.
ilistInitializer list with values to insert.
Returns
Iterator pointing to the first element inserted, or pos if ilist is empty.

Given the size n of ilist, this function results in undefined behaviour if size() + n > capacity().

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

◆ insert() [4/4]

constexpr iterator bio::ranges::small_vector< char , capacity_ >::insert ( const_iterator  pos,
value_type const  value 
)
inlineconstexprnoexceptinherited

Inserts value before position in the container.

Parameters
posIterator before which the content will be inserted. pos may be the end() iterator.
valueElement value to insert.
Returns
Iterator pointing to the inserted value.

Inserting a value although the maximum capacity is reached is undefined behaviour.

Complexity

Worst-case linear in size().

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

◆ max_size()

constexpr size_type bio::ranges::small_vector< char , capacity_ >::max_size ( ) const
inlineconstexprnoexceptinherited

Returns the maximum number of elements the container is able to hold and resolves to capacity_.

Returns
The number of elements in the container.

This value typically reflects the theoretical limit on the size of the container. At runtime, the size of the container may be limited to a value smaller than max_size() by the amount of RAM available.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ operator std::string_view()

template<size_t capacity_>
constexpr bio::ranges::small_string< capacity_ >::operator std::string_view ( ) const
inlineconstexpr

Implicit conversion to std::string_view (same as calling bio::ranges::small_string::view() ).

Exceptions

Strong exception guarantee. No data is modified.

Complexity

Constant.

◆ operator=()

template<size_t capacity_>
template<size_t N>
constexpr small_string & bio::ranges::small_string< capacity_ >::operator= ( char const (&)  _lit[N])
inlineconstexprnoexcept

Assign from literal.

Parameters
_litThe literal to assign the string from.

The char literal is expected to be null-terminated (asserted in debug-mode). If it is not, the last character will be lost when copying to the instance of small_string.

Complexity

Linear in the size of _lit.

Exceptions

No-throw guarantee.

◆ operator[]() [1/2]

constexpr const_reference bio::ranges::small_vector< char , capacity_ >::operator[] ( size_type const  i) const
inlineconstexprnoexceptinherited

Return the i-th element.

Parameters
iThe element to retrieve.
Returns
A reference to the value at position i.

Accessing an element behind the last causes undefined behaviour. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ operator[]() [2/2]

constexpr reference bio::ranges::small_vector< char , capacity_ >::operator[] ( size_type const  i)
inlineconstexprnoexceptinherited

Return the i-th element.

Parameters
iThe element to retrieve.
Returns
A reference to the value at position i.

Accessing an element behind the last causes undefined behaviour. In debug mode an assertion checks the size of the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ pop_back()

template<size_t capacity_>
constexpr void bio::ranges::small_string< capacity_ >::pop_back ( )
inlineconstexprnoexcept

Removes the last element of the container.

Calling pop_back() on an empty container is undefined. In debug mode an assertion will be thrown.

No iterators or references except for back() and end() are invalidated.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ push_back()

template<size_t capacity_>
constexpr void bio::ranges::small_string< capacity_ >::push_back ( char const  value)
inlineconstexprnoexcept

Appends the given element value to the end of the container.

Parameters
valueThe value to append.

If the new size() is greater than capacity() this is undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ resize() [1/2]

template<size_t capacity_>
constexpr void bio::ranges::small_string< capacity_ >::resize ( size_type const  count)
inlineconstexprnoexcept

Resizes the container to contain count elements.

Parameters
[in]countThe new size.

If count is greater than capacity this is undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ resize() [2/2]

template<size_t capacity_>
constexpr void bio::ranges::small_string< capacity_ >::resize ( size_type const  count,
char const  value 
)
inlineconstexprnoexcept

Resizes the container to contain count elements.

Parameters
[in]countThe new size.

If count is greater than capacity this is undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

Parameters
[in]valueAppend copies of value when resizing.

◆ size()

constexpr size_type bio::ranges::small_vector< char , capacity_ >::size ( ) const
inlineconstexprnoexceptinherited

Returns the number of elements in the container, i.e. std::distance(begin(), end()).

Returns
The number of elements in the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ str()

template<size_t capacity_>
std::string bio::ranges::small_string< capacity_ >::str ( ) const
inline

Returns the content represented as std::string.

Returns
std::string The stored string.

Exceptions

Strong exception guarantee. No data is modified.

Complexity

Linear in the size of the string.

◆ swap()

constexpr void bio::ranges::small_vector< char , capacity_ >::swap ( small_vector< char, capacity_+1 > &  rhs)
inlineconstexprnoexceptinherited

Swap contents with another instance.

Parameters
rhsThe other instance to swap with.

Complexity

Linear in the size of both containers.

Exceptions

No-throw guarantee if value_type is std::is_nothrow_copy_constructible.

◆ view()

template<size_t capacity_>
constexpr std::string_view bio::ranges::small_string< capacity_ >::view ( ) const
inlineconstexpr

Returns the content represented as std::string_view.

Returns
std::string_view The stored string.

Exceptions

Strong exception guarantee. No data is modified.

Complexity

Constant.

Friends And Related Function Documentation

◆ operator+

template<size_t capacity_>
template<size_t capacity2>
constexpr friend small_string< capacity_+capacity2 > operator+ ( small_string< capacity_ > const &  lhs,
small_string< capacity2 > const &  rhs 
)
friend

Concatenates two small_strings by returning a new small_string.

Parameters
lhsThe left-hand-side to concat with.
rhsThe right-hand-side to concat with.
Returns
small_string<capacity_ + capacity2> The new small_string with size capacity_ + capacity2.

Exceptions

No-throw guarantee.

Complexity

Linear in the size of the strings.

◆ operator<<

template<size_t capacity_>
std::ostream & operator<< ( std::ostream os,
small_string< capacity_ > const &  str 
)
friend

Formatted output for the bio::ranges::small_string.

Parameters
[in,out]osThe std::basic_ostream to write to.
[in]strThe bio::ranges::small_string to read from.
Returns
os.

Internally calls os << str.str().


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