Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

@fsb4000

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()};
}

@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.

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