We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
在
// fill_init 函数 template <class T> void vector<T>:: fill_init(size_type n, const value_type& value) { const size_type init_size = mystl::max(static_cast<size_type>(16), n); init_space(n, init_size); mystl::uninitialized_fill_n(begin_, n, value); `}`
中,为什么要有 const size_type init_size = mystl::max(static_cast<size_type>(16), n); 的动作呢
The text was updated successfully, but these errors were encountered:
估计是为了减少内存碎片,避免过于小的单次动态分配。
但是我觉得当 n == 0 时应该直接退出并且不进行动态分配。 @Alinshans
n == 0
Sorry, something went wrong.
No branches or pull requests
在
中,为什么要有 const size_type init_size = mystl::max(static_cast<size_type>(16), n); 的动作呢
The text was updated successfully, but these errors were encountered: