Annotate noexcept and constexpr with HEDLEY, and add interval containment, ChaCha, and the dyadic range tables.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ryan Henry 2026-09-24 20:44:07 -06:00
parent 875f09fec1
commit 0d8a5a8131
97 changed files with 9212 additions and 1159 deletions

View file

@ -39,6 +39,7 @@ namespace detail
{
template <typename PRG>
HEDLEY_NO_THROW
typename PRG::block_type mask_master(typename PRG::block_type master) noexcept
{
unsigned char raw[sizeof(master)];
@ -140,6 +141,7 @@ struct buffered_slot
return lane_codec<PRG, T>::at(seed_, index);
}
HEDLEY_NO_THROW
std::uint64_t sampled() const noexcept { return absolute_pos_; }
private:
@ -165,7 +167,13 @@ typename PRG::block_type sample_master_seed()
return dpf::uniform_sample<typename PRG::block_type>();
}
/// Fixed lanes. Lane `I` is `PRG::eval(master, I)`.
/// Forward cursor over one PRG stream per value type.
///
/// `get<I>()` and `fill<I>()` consume the cursor. `at<I>(index)` reads an
/// absolute index and leaves the cursor where it is. `sampled<I>()` reports
/// how far `get` and `fill` have advanced. `per_stream_buffer_elems` is at
/// least 1.
/// @snippet evaluation/buffered_prg.cpp buffered-prg
template <typename PRG, typename... Ts>
class buffered_prg
{
@ -184,6 +192,7 @@ public:
buffers_(make_buffers(per_stream_buffer_elems))
{ }
HEDLEY_NO_THROW
const seed_type & seed() const noexcept { return seed_; }
template <std::size_t I>
@ -208,6 +217,7 @@ public:
}
template <std::size_t I>
HEDLEY_NO_THROW
std::uint64_t sampled() const noexcept
{
static_assert(I < stream_count, "stream index out of range");
@ -238,9 +248,12 @@ private:
template <typename... Ts>
using aes_buffered_prg = buffered_prg<dpf::prg::aes128, Ts...>;
/// Dynamic lanes of one value type. `value_at(role, index)` and
/// `mask_at(role, index)` are independent of call order. A window cache
/// refills from the requested index.
/// Seekable value and mask streams for a runtime set of roles.
///
/// `value_at(role, index)` and `mask_at(role, index)` are independent of
/// call order. A repeated index returns the same element. `window` is at
/// least 1.
/// @snippet evaluation/buffered_prg.cpp lane-table
template <typename T, typename PRG = dpf::prg::aes128>
class lane_table
{
@ -267,6 +280,7 @@ public:
lane_table(lane_table &&) = default;
lane_table & operator=(lane_table &&) = default;
HEDLEY_NO_THROW
const seed_type & seed() const noexcept { return seed_; }
T value_at(std::uint32_t role, std::uint64_t index) const