Loading...
Searching...
No Matches
ring_count.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <limits>
5#include <stdexcept>
6
7namespace primitive {
8
9// The histogram and per-atom counts use int at the public API boundary.
10// Refuse a count that cannot be represented before doing the addition.
11inline void addRingCount(int &count, std::int64_t increment = 1) {
12 if (count < 0 || increment < 0 ||
13 increment > static_cast<std::int64_t>(std::numeric_limits<int>::max()) -
14 count) [[unlikely]] {
15 throw std::overflow_error("primitive ring count exceeds int range");
16 }
17 count += static_cast<int>(increment);
18}
19
20} // namespace primitive
Functions for generating primitive rings.
Definition franzblau.hpp:77
void addRingCount(int &count, std::int64_t increment=1)