Skip to content

back always returns '\0' #71

@joro75

Description

@joro75

This is regarding:

constexpr const_reference cstring::back() const noexcept 
{ 
     return chars_[N]; 
}

This back member returns chars_[N], which is the trailing '\0' that cstring stores for C‑string termination.

The last meaningful character sits at index N - 1, so shouldn't back() use return chars_[N - 1] to mirror the std::basic_string::back behavior and avoid always returning the null terminator?
A non-null check on the 'N' is not needed as it is already guaranteed by the constructor that N > 0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions