Skip to main content

fixstr::basic_fixed_string::front

1#
[[nodiscard]] constexpr reference front() noexcept requires N != 0;
2#
[[nodiscard]] constexpr const_reference front() const noexcept requires N != 0;

Returns reference to the first character in the string.

The function is not provided for empty strings.

note

Note that requires is used only in the documentation purposes. In order to support C++17 the implementation uses SFINAE.

Return value#

Reference to the first element.

Complexity#

Constant.

Example#

// clang-format off#include <fixed_string.hpp>#include <iostream>
int main(){    {        fixstr::fixed_string s = "Exemplary";        char& f = s.front();        f = 'e';        std::cout << s << '\n'; // "exemplary"    }
    {        constexpr const fixstr::fixed_string c = "Exemplary";        char const& f = c.front();        std::cout << &f << '\n'; // "Exemplary"    }}
Output:
exemplaryExemplary