Skip to content

fix: add proof for the std::pmr::vector that it only use the stack space buffer instead of heap#77

Merged
Charliechen114514 merged 1 commit into
Awesome-Embedded-Learning-Studio:mainfrom
YukunJ:add-more-proof
Jun 23, 2026
Merged

fix: add proof for the std::pmr::vector that it only use the stack space buffer instead of heap#77
Charliechen114514 merged 1 commit into
Awesome-Embedded-Learning-Studio:mainfrom
YukunJ:add-more-proof

Conversation

@YukunJ

@YukunJ YukunJ commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Brief: Augment the code sample in std::pmr::vector section.

The tutorial states "vector 的内存来自栈上 buffer,零全局堆分配" without actually prove it.

QA:

see godbolt reference: https://godbolt.org/z/WxjTb8oW5

@Charliechen114514

@Charliechen114514

Copy link
Copy Markdown
Member

@YukunJ

感谢贡献!(最近才知道可以@人提示,手动捂脸)

的确这个地方少了一部分论证。您用地址范围比对把这点坐实了:v.data() 落在 [buffer, buffer+sizeof(buffer)] 内,论证清晰,附的 godbolt 链接也很贴心!

PS: 刚好这边就在小重构Vol3的内容,13-custom-allocators.md 之后会迁移到一个子目录中!届时我会把这段证明一起带到新位置,不会丢。;)

Thank you for your contribution! (I only recently learned that you can @ someone for a prompt)

Indeed, this part of the argument was lacking. You have confirmed it using address range comparison: v.data() falls within [buffer, buffer + sizeof(buffer)], making the argument clear. The attached Godbolt link is also very considerate!

PS: I happen to be doing a minor refactoring of Vol3 here. 13-custom-allocators.md you changed will be moved to a subdirectory! At that time, I will also move this proof to the new location, it won't be lost ;)

@Charliechen114514 Charliechen114514 merged commit 97f0b1f into Awesome-Embedded-Learning-Studio:main Jun 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants