10 static_cast<std::uint64_t
>(std::numeric_limits<std::size_t>::max());
15 std::uint64_t& product)
noexcept {
16 if (lhs != 0 && rhs >
maximum / lhs)
return false;
24 std::uint64_t& sum)
noexcept {
30template <
typename Element>
32 std::uint64_t target_max_bytes,
33 std::uint64_t* bytes =
nullptr) noexcept {
34 std::uint64_t allocation_bytes = 0;
36 target_max_bytes, allocation_bytes))
38 if (bytes) *bytes = allocation_bytes;
45template <
typename Element>
47 std::uint64_t repetitions,
48 std::uint64_t target_max_bytes,
49 std::uint64_t& aggregate_bytes)
noexcept {
50 std::uint64_t one_allocation_bytes = 0;
52 &one_allocation_bytes)
54 std::numeric_limits<std::uint64_t>::max(), aggregate_bytes);
60 : allocation_ceiling_(allocation_ceiling) {}
62 template <
typename Element>
63 bool add(std::uint64_t elements)
noexcept {
64 std::uint64_t bytes = 0;
69 template <
typename Element>
71 std::uint64_t repetitions)
noexcept {
72 std::uint64_t bytes = 0;
74 elements_per_allocation, repetitions, allocation_ceiling_, bytes)
83 std::uint64_t
total() const noexcept {
return total_; }
86 std::uint64_t allocation_ceiling_ = 0;
87 std::uint64_t total_ = 0;
CheckedRetainedByteCharge(std::uint64_t allocation_ceiling) noexcept
Definition checked_allocation.hpp:59
bool add(std::uint64_t elements) noexcept
Definition checked_allocation.hpp:63
std::uint64_t total() const noexcept
Definition checked_allocation.hpp:83
bool add_retained_bytes(std::uint64_t bytes) noexcept
Definition checked_allocation.hpp:78
bool add_repeated(std::uint64_t elements_per_allocation, std::uint64_t repetitions) noexcept
Definition checked_allocation.hpp:70
Definition additive_bank.hpp:218
bool checked_repeated_allocation_bytes(std::uint64_t elements_per_allocation, std::uint64_t repetitions, std::uint64_t target_max_bytes, std::uint64_t &aggregate_bytes) noexcept
Validate one allocation against its address ceiling, then compute the aggregate retained charge for r...
Definition checked_allocation.hpp:46
bool checked_capacity_product(std::uint64_t lhs, std::uint64_t rhs, std::uint64_t maximum, std::uint64_t &product) noexcept
Definition checked_allocation.hpp:12
bool checked_capacity_sum(std::uint64_t lhs, std::uint64_t rhs, std::uint64_t maximum, std::uint64_t &sum) noexcept
Definition checked_allocation.hpp:21
@ maximum
Definition spectrum_trace.hpp:34
constexpr std::uint64_t kTargetAddressMaximumBytes
Definition checked_allocation.hpp:9
bool checked_allocation_bytes(std::uint64_t elements, std::uint64_t target_max_bytes, std::uint64_t *bytes=nullptr) noexcept
Definition checked_allocation.hpp:31