On December 5, 2019 9:35:35 AM EST, Phil Endecott via Boost
Peter Dimov wrote:
- a function that checks whether the remaining capacity is at least n should be added. I suggest the name
bool can_fit( std::size_t n ) const noexcept;
although my previous choice of "has_capacity_for" has merit too.
I suggest the simpler "fits".
Make this a free function template and you can use it with other containers:
template <typename CONTAINER> bool can_fit( const CONTAINER& C, typename CONTAINER::size_type n ) noexcept { return C.capacity() - C.size() >= n; }
That's a nice idea, especially with the name "fits". :) However, if you reverse the parameters, "fits_in" would be a better name as it indicates the argument order. -- Rob (Sent from my portable computation device.)