23#include <boost/array.hpp>
70template<
typename Stat_set_t,
size_t N>
79 static_assert(std::is_default_constructible_v<Stat_set>,
80 "Stat_set must be default-constructible (T{} required).");
85 static constexpr size_t S_N = N;
87 static_assert(
S_N != 0,
"Have to store at least 1 Stat_set.");
191template<typename Tag_t, typename Stat_set_t,
size_t N>
206 static constexpr size_t S_N = N;
225template<
typename Stat_set_t,
size_t N>
231 return const_cast<Stat_set_list*
>(
this)->stats_mutable<IDX>();
234template<
typename Stat_set_t,
size_t N>
238 static_assert(IDX <
S_N,
"Compile-time Stat_set index exceeds compile-time capacity.");
242template<
typename Stat_set_t,
size_t N>
249template<
typename Stat_set_t,
size_t N>
252 assert((idx <
S_N) &&
"Run-time Stat_set index exceeds compile-time capacity. "
253 "Can use stats() for compile-time safety, if `idx` is known at compile-time.");
257template<
typename Stat_set_t,
size_t N>
263template<
typename Stat_set_t,
size_t N>
266 return stats_mutable<0>();
269template<
typename Stat_set_t,
size_t N>
278template<
typename Tag_t,
typename Stat_set_t,
size_t N>
A straightforward global/singleton holder of a single Stat_set_list<Stat_set, S_N>; the template para...
Tag_t Tag
The template parameter Tag_t.
Stat_set_t Stat_set
See Stat_set_list.
Global_stats()=delete
Forbid instantiation, for it is pointless.
static Stat_set_list< Stat_set, N > & get()
Thread-safely default-constructs or accesses the one Stat_set_list<Stat_set, S_N> for Tag.
Dead-simple collection (essentially a statically-sized array) of up-to-N Stat_sets,...
static constexpr size_t S_N
The template parameter N.
void reset()
Purely as syntactic sugar: executes stats_reset(&s, {}) for each Stat_set s of S_N stored in *this.
auto stats() const -> const Stat_set &
Read-only access to the compile-time-specified-slot-indexed Stat_set: for stat consumption.
Stat_set & stats_mutable_default()
Mutable access to the 0th Stat_set: for stat updates.
Stat_set_t Stat_set
The template parameter Stat_set_t.
const Stat_set & stats_default() const
Read-only access to the 0th Stat_set: for stat consumption.
boost::array< Stat_set, S_N > m_sets
Data.
Stat_set & stats_mutable_at(size_t idx)
Mutable access to the run-time-specified-slot-indexed Stat_set: for stat updates.
auto stats_mutable() -> Stat_set &
Mutable access to the compile-time-specified-slot-indexed Stat_set: for stat updates.
const Stat_set & stats_at(size_t idx) const
Read-only access to the run-time-specified-slot-indexed Stat_set: for stat consumption.
Sub-module of flow::util providing lightweight facilities for working with simple structs of stat cou...
void stats_reset(Stat_set *target_stats, const Stat_set &fresh_stats)
With the help of a freshly-initialized Stat_set, resets the target Stat_set so as to immediately begi...