std::hive<T,Allocator>::is_within_hard_limits
static constexpr bool is_within_hard_limits( std::hive_limits limits ) noexcept; | (since C++26) |
Checks if given block capacity limits is within block capacity hard limits. Equivalent to
constexpr auto hard{block_capacity_hard_limits()};
return hard.min <= limits.min and limits.min <= limits.max and limits.max <= hard.max;
Return value
true if limits is within block capacity hard limits.
Complexity
Constant.
Example
#include <hive>
#include <iostream>
using Garage = std::hive<int>;
static_assert(
Garage::is_within_hard_limits(Garage::block_capacity_hard_limits()) &&
Garage::is_within_hard_limits(Garage::block_capacity_default_limits())
);
int main()
{
auto limits{std::hive<int>::block_capacity_hard_limits()};
auto print = [](std::hive_limits limits)
{
std::cout << "Limits {min: " << limits.min << ", max: " << limits.max << "} is ";
std::cout << (Garage::is_within_hard_limits(limits) ? "within" : "without")
<< " block capacity hard limits\n";
};
print(limits);
limits.min = 0;
print(limits);
}
Possible output:
Limits {min: 3, max: 255} is within block capacity hard limits
Limits {min: 0, max: 255} is without block capacity hard limits
See also
| returns the number of elements that can be held in currently allocated storage (public member function) |
|
| reserves storage (public member function) |
|
| reduces memory usage by freeing unused memory (public member function) |
|
| deallocates reserved blocks and reduces capacity accordingly (public member function) |
|
| returns current block capacity limits (public member function) |
|
|
[static] | returns block capacity default limits (public static member function) |
|
[static] | returns block capacity hard limits (public static member function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/container/hive/is_within_hard_limits