Skip to main content

fixstr::basic_fixed_string::back

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

Returns reference to the last 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 last element.

Complexity#

Constant.

Example#

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