Files
leleka/engine/strata/src/core/conversation_checked.hpp
T
Pavlo Ratushnyi 4013e0c9bd
Desktop foundation / core (macos-latest) (push) Canceled after 0s
Desktop foundation / core (windows-latest) (push) Canceled after 0s
Linux / verify (push) Canceled after 0s
Linux / keyless-cuda (push) Canceled after 0s
Desktop foundation / core (ubuntu-latest) (push) Failing after 28s
Linux / static-cuda-package (push) Canceled after 0s
Linux / hosted-cuda-package (push) Canceled after 0s
Linux / linux-static-cli (push) Canceled after 0s
Linux / linux-cli-container (push) Canceled after 0s
Linux / release-cli (push) Canceled after 0s
Import tracked Strata Next source snapshot
2026-10-05 18:15:08 +02:00

25 lines
704 B
C++

#pragma once
#include <cstddef>
#include <cstdint>
#include <initializer_list>
#include <limits>
namespace strata::core::conversation_detail {
inline bool add(size_t& total, size_t n) {
if (n > std::numeric_limits<size_t>::max() - total) return false;
total += n;
return true;
}
inline bool product(size_t& out, std::initializer_list<uint64_t> factors) {
size_t value = 1;
for (uint64_t factor : factors) {
if (factor > std::numeric_limits<size_t>::max() ||
(factor && value > std::numeric_limits<size_t>::max() / factor)) return false;
value *= (size_t) factor;
}
out = value;
return true;
}
} // namespace strata::core::conversation_detail