Closed cmazakas closed 5 months ago
fields_base needs a means of controlling how it allocates.
fields_base
For this, a two argument overload is introduced along with 2 convenience overloads.
Consider: fields_base(size_type initial_size, size_type max_size);
fields_base(size_type initial_size, size_type max_size);
The container will not allocate beyond max_size and requests for memory will throw bad_alloc (or similar).
max_size
bad_alloc
fields_base(0, 16 * 1024) is permitted, and will not allocate.
fields_base(0, 16 * 1024)
fields_base() can then become fields_base():fields_base(0, max_size_) where max_size_ is some defaulted member, perhaps to size_type{-1}.
fields_base()
fields_base():fields_base(0, max_size_)
max_size_
size_type{-1}
// synopsis fields_base(size_type initial_size, size_type max_size); fields_base(size_type size); // initial_size = max_size fields_base() noexcept; // initial_size = 0, max_size = impl-defined
fields_base
needs a means of controlling how it allocates.For this, a two argument overload is introduced along with 2 convenience overloads.
Consider:
fields_base(size_type initial_size, size_type max_size);
The container will not allocate beyond
max_size
and requests for memory will throwbad_alloc
(or similar).fields_base(0, 16 * 1024)
is permitted, and will not allocate.fields_base()
can then becomefields_base():fields_base(0, max_size_)
wheremax_size_
is some defaulted member, perhaps tosize_type{-1}
.