Skip to main content

fixstr::basic_fixed_string::begin
fixstr::basic_fixed_string::cbegin

1#
[[nodiscard]] constexpr iterator begin() noexcept;
2#
[[nodiscard]] constexpr const_iterator begin() const noexcept;
3#
[[nodiscard]] constexpr const_iterator cbegin() const noexcept;

Returns an iterator to the first character of the fixed string.

begin() returns a mutable or constant iterator, depending on the constness of *this.

cbegin() always returns a constant iterator. It is equivalent to std::as_const(*this).begin()

Image explaining iterators

Parameters#

(none)

Return value#

Iterator to the first character.

Complexity#

Constant.

Example#

#include <fixed_string.hpp>#include <iostream>#include <string>#include <utility>
int main(){    fixstr::fixed_string s = "Exemplar";    *s.begin() = 'e';    std::cout << s << '\n';
    auto i1 = s.cbegin();    std::cout << *i1 << '\n';    // *i1 = 'E'; // error: i1 is a constant iterator
    auto i2 = std::as_const(s).begin();    std::cout << *i2 << '\n';    // *i2 = 'E'; // error: i2 is a constant iterator}
Output:
exemplaree