Namespaces
Variants

std::hive<T,Allocator>::is_within_hard_limits

From cppreference.com
 
 
 
 
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) [edit]
reserves storage
(public member function) [edit]
reduces memory usage by freeing unused memory
(public member function) [edit]
deallocates reserved blocks and reduces capacity accordingly
(public member function) [edit]
returns current block capacity limits
(public member function) [edit]
returns block capacity default limits
(public static member function) [edit]
returns block capacity hard limits
(public static member function) [edit]