Alinshans / MyTinySTL

Achieve a tiny STL in C++11
Other
11.38k stars 3.24k forks source link

关于容器中的allocator_type get_allocator()函数 #128

Open alwaysmil opened 1 year ago

alwaysmil commented 1 year ago

vector.h中:allocator_type get_allocator() { return data_allocator(); } list.h中:allocator_type get_allocator() { return node_allocator(); } deque.h中:allocator_type get_allocator() { return allocator_type(); } 为什么函数返回值类型都是allocator_type,但是函数体中 return 的确是不同的对象呢?

frederick-vs-ja commented 1 year ago

目前这个区别没有意义。 MyTinySTL 的容器只支持自己的 mystl::allocator ,而同系列的分配器都能彼此间相互隐式转换。