Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alwaysmil opened this issue Mar 8, 2023 · 1 comment
Open

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

alwaysmil opened this issue Mar 8, 2023 · 1 comment

Comments

@alwaysmil
Copy link

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
Copy link
Contributor

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

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

No branches or pull requests

2 participants