SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
seqan3::small_string< capacity_ > Class Template Reference

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

#include <seqan3/range/container/small_string.hpp>

+ Inheritance diagram for seqan3::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 = const value_type &
 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 = detail::min_viable_uint_t< capacity_ >
 The size_type type.
 
Associated types
using value_type = char
 The value_type type.
 
using reference = value_type &
 The reference type.
 
using const_reference = const value_type &
 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 = 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. More...
 
constexpr small_string (char const c) noexcept
 Construction from char. More...
 
template<size_t N>
constexpr small_stringoperator= (char const (&_lit)[N]) noexcept
 Assign from literal. More...
 
template<size_t N>
constexpr void assign (char const (&_lit)[N]) noexcept
 Assign from literal. More...
 
template<std::forward_iterator begin_it_type, typename end_it_type >
constexpr void assign (begin_it_type begin_it, end_it_type end_it) noexcept
 Assign from pair of iterators. More...
 
Modifiers
constexpr void clear () noexcept
 Removes all elements from the container. More...
 
constexpr void push_back (char const value) noexcept
 Appends the given element value to the end of the container. More...
 
constexpr void pop_back () noexcept
 Removes the last element of the container. More...
 
constexpr void resize (size_type const count) noexcept
 Resizes the container to contain count elements. More...
 
constexpr void resize (size_type const count, char const value) noexcept
 Resizes the container to contain count elements. More...
 
constexpr small_stringerase (size_type index=0, size_type count=max_size()) noexcept
 Removes specified elements from the container. More...
 
Conversion
std::string str () const
 Returns the content represented as std::string. More...
 
constexpr const char * c_str () const noexcept
 Returns the content represented as 0-terminated c-style string. More...
 
 operator std::string () const
 Implicit conversion to std::string which delegates to seqan3::small_string::str(). More...
 
Constructors, destructor and assignment
constexpr void assign (std::initializer_list< value_type > ilist) noexcept(is_noexcept)
 Assign from std::initializer_list. More...
 
constexpr void assign (size_type const count, value_type const value) noexcept(is_noexcept)
 Assign with count times value. More...
 
constexpr void assign (other_range_t &&range) noexcept(is_noexcept)
 Assign from a different range. More...
 
Iterators
constexpr iterator begin () noexcept
 Returns the begin to the string.
 
constexpr const_iterator begin () const noexcept
 Returns the begin to the string. More...
 
constexpr const_iterator cbegin () const noexcept
 Returns the begin to the string. More...
 
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. More...
 
constexpr const_iterator cend () const noexcept
 Returns iterator past the end of the vector. More...
 
Element access
reference at (size_type const i)
 Return the i-th element. More...
 
const_reference at (size_type const i) const
 Return the i-th element. More...
 
constexpr reference operator[] (size_type const i) noexcept
 Return the i-th element. More...
 
constexpr const_reference operator[] (size_type const i) const noexcept
 Return the i-th element. More...
 
constexpr reference front () noexcept
 Return the first element. Calling front on an empty container is undefined. More...
 
constexpr const_reference front () const noexcept
 Return the first element. Calling front on an empty container is undefined. More...
 
constexpr reference back () noexcept
 Return the last element. More...
 
constexpr const_reference back () const noexcept
 Return the last element. More...
 
constexpr value_typedata () noexcept
 Direct access to the underlying array.
 
constexpr const value_typedata () const noexcept
 Direct access to the underlying array. More...
 
Capacity
constexpr bool empty () const noexcept
 Checks whether the container is empty. More...
 
constexpr size_type size () const noexcept
 Returns the number of elements in the container, i.e. std::distance(begin(), end()). More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
constexpr iterator erase (const_iterator begin_it, const_iterator end_it) noexcept
 Removes specified elements from the container. More...
 
constexpr iterator erase (const_iterator pos) noexcept
 Removes specified elements from the container. More...
 
constexpr void swap (small_vector &rhs) noexcept(is_noexcept)
 Swap contents with another instance. More...
 
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.
 
Iterators
constexpr iterator begin () noexcept
 Returns the begin to the string.
 
constexpr const_iterator begin () const noexcept
 Returns the begin to the string. More...
 
constexpr const_iterator cbegin () const noexcept
 Returns the begin to the string. More...
 
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. More...
 
constexpr const_iterator cend () const noexcept
 Returns iterator past the end of the vector. More...
 
Element access
reference at (size_type const i)
 Return the i-th element. More...
 
const_reference at (size_type const i) const
 Return the i-th element. More...
 
constexpr reference operator[] (size_type const i) noexcept
 Return the i-th element. More...
 
constexpr const_reference operator[] (size_type const i) const noexcept
 Return the i-th element. More...
 
constexpr reference front () noexcept
 Return the first element. Calling front on an empty container is undefined. More...
 
constexpr const_reference front () const noexcept
 Return the first element. Calling front on an empty container is undefined. More...
 
constexpr reference back () noexcept
 Return the last element. More...
 
constexpr const_reference back () const noexcept
 Return the last element. More...
 
constexpr value_typedata () noexcept
 Direct access to the underlying array.
 
constexpr const value_typedata () const noexcept
 Direct access to the underlying array. More...
 

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. More...
 
Input/output
std::ostreamoperator<< (std::ostream &os, small_string const &str)
 Formatted output for the seqan3::small_string. More...
 
std::istreamoperator>> (std::istream &is, small_string &str)
 Formatted input for the seqan3::small_string. More...
 

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.
 
 small_string (char const) -> small_string< 1 >
 Deduces small_string from char.
 

Detailed Description

template<size_t capacity_>
class seqan3::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).

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).

Usage:

int main()
{
constexpr seqan3::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
seqan3::debug_stream << sm.size() << '\n'; // 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()};
seqan3::debug_stream << sm << sm_string << sm_cstr << '\n'; // prints "hellohellohello"
}

Constructor & Destructor Documentation

◆ small_string() [1/2]

template<size_t capacity_>
template<size_t N>
constexpr seqan3::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.

◆ small_string() [2/2]

template<size_t capacity_>
constexpr seqan3::small_string< capacity_ >::small_string ( char const  c)
inlineexplicitconstexprnoexcept

Construction from char.

Parameters
cThe character to construct the small_string for.

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 >
constexpr void seqan3::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 seqan3::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 seqan3::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 seqan3::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 seqan3::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 seqan3::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 seqan3::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 seqan3::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.

◆ back() [2/2]

constexpr reference seqan3::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 seqan3::small_vector< char , capacity_ >::begin
inlineconstexprnoexceptinherited

Returns the begin to the string.

◆ c_str()

template<size_t capacity_>
constexpr const char* seqan3::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.

◆ cbegin()

constexpr const_iterator seqan3::small_vector< char , capacity_ >::cbegin
inlineconstexprnoexceptinherited

Returns the begin to the string.

◆ cend()

constexpr const_iterator seqan3::small_vector< char , capacity_ >::cend
inlineconstexprnoexceptinherited

Returns iterator past the end of the vector.

◆ clear()

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

Removes all elements from the container.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ data()

constexpr const value_type* seqan3::small_vector< char , capacity_ >::data
inlineconstexprnoexceptinherited

Direct access to the underlying array.

◆ empty()

constexpr bool seqan3::small_vector< char , capacity_ >::empty
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 seqan3::small_vector< char , capacity_ >::end
inlineconstexprnoexceptinherited

Returns iterator past the end of the vector.

◆ erase() [1/3]

constexpr iterator seqan3::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 seqan3::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& seqan3::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 seqan3::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.

◆ front() [2/2]

constexpr reference seqan3::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 seqan3::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 seqan3::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 seqan3::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 seqan3::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.

◆ operator std::string()

template<size_t capacity_>
seqan3::small_string< capacity_ >::operator std::string ( ) const
inline

Implicit conversion to std::string which delegates to seqan3::small_string::str().

Exceptions

Strong exception guarantee. No data is modified.

Complexity

Linear in the size of the string.

◆ operator=()

template<size_t capacity_>
template<size_t N>
constexpr small_string& seqan3::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 seqan3::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 seqan3::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 seqan3::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 seqan3::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 seqan3::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 seqan3::small_string< capacity_ >::resize ( size_type const  count,
char const  value 
)
inlineconstexprnoexcept

Resizes the container to contain count elements.

Parameters
valueAppend copies of value when resizing.
[in]countThe new size.

If count is greater than capacity this is undefined behaviour.

Complexity

Constant.

Exceptions

No-throw guarantee.

◆ size()

constexpr size_type seqan3::small_vector< char , capacity_ >::size
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 seqan3::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 seqan3::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.

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 seqan3::small_string.

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

Internally calls os << str.str().

◆ operator>>

template<size_t capacity_>
std::istream& operator>> ( std::istream is,
small_string< capacity_ > &  str 
)
friend

Formatted input for the seqan3::small_string.

Parameters
[in,out]isThe std::basic_istream to read from.
[out]strThe seqan3::small_string to write to.
Returns
is.

Reads at most seqan3::small_string::max_size characters from the stream. If a stream error occurred or no characters could be extracted the std::ios_base::failbit is set. This may throw an exception.


The documentation for this class was generated from the following file:
debug_stream.hpp
Provides seqan3::debug_stream and related types.
std::string
seqan3::small_string
Implements a small string that can be used for compile time computations.
Definition: small_string.hpp:42
small_string.hpp
A constexpr string implementation to manipulate string literals at compile time.
std::string::c_str
T c_str(T... args)
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42