CppCon 2015: Andrei Alexandrescu “std::allocator...”
CppConYouTube ↗
延伸阅读 1
字幕解读
Andrei Alexandrescu 在 CppCon 2015 提出一种组织内存分配器的思路:先设计能组合的小部件,再按请求选用不同策略。他把指针和长度一起作为内存块传递,并用后备分配器说明为什么接口还要考虑释放。第一次分配失败时可以换用另一个分配器,但释放时必须知道该把内存块交回哪一个。在他的示例里,主分配器能判断某个块是否归自己所有。
存档字幕(转写方式未注明) ↗ · 引文按字幕原文展示,可点时间戳回看片段。
补充字幕原文 2
it has the pointer and the lengthif you want to write an allocator you got to make it composable