Skip to content

Add resize_and_overwrite - #53

Closed
Andersama wants to merge 1 commit into
martinus:mainfrom
Andersama:patch-1
Closed

Add resize_and_overwrite#53
Andersama wants to merge 1 commit into
martinus:mainfrom
Andersama:patch-1

Conversation

@Andersama

Copy link
Copy Markdown
Contributor

Following feedback from #49 I've written resize_and_overwrite using https://en.cppreference.com/w/cpp/string/basic_string/resize_and_overwrite as a guide.

Following feedback from martinus#49 I've written `resize_and_overwrite` using https://en.cppreference.com/w/cpp/string/basic_string/resize_and_overwrite as a guide.
@martinus

Copy link
Copy Markdown
Owner

Thanks, and sorry for the delay. Picked this up in #59, which keeps your commit.

Three things needed changing: op was called with the old size rather than count (the standard passes count, and callbacks need it to know how much space they have), and op throwing caused a double-free when shrinking and leaked every element when growing. #59 fixes those and adds test/unit/resize_and_overwrite.cpp with 11 cases.

Your point in #49 about the signature being confusing still stands, for what it's worth — but I'd rather match the standard exactly than invent a variant with the same signature and different meaning.

@martinus martinus closed this in #59 Jul 27, 2026
@martinus

Copy link
Copy Markdown
Owner

Merged as fd04160 via #59 — your commit is in main with your authorship intact. GitHub can't auto-close this because the repo uses rebase-merge, which rewrites SHAs. Thanks for pushing on this across both PRs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants