Skip to content

<string>: Should string::substr forward the allocator to the newly created string? #3022

Description

@fsb4000

The C++ Standard doesn't say that: https://eel.is/c++draft/string.substr

STL/stl/inc/xstring

Lines 4673 to 4676 in 5aae678

_NODISCARD _CONSTEXPR20 basic_string substr(const size_type _Off = 0, const size_type _Count = npos) const {
// return [_Off, _Off + _Count) as new string
return basic_string{*this, _Off, _Count, get_allocator()};
}

Casey Carter (@CaseyCarter) agreed. He also assumed that we'll fix this when implementing WG21-P2438 but I still decided to create an issue to not forget about it.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions