Skip to content

Commit

Permalink
CachedBitGenerator: value_type -> result_type to fix for libcxx
Browse files Browse the repository at this point in the history
  • Loading branch information
veprbl authored and wdconinc committed Dec 19, 2023
1 parent efbad92 commit 19e82c5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions external/algorithms/core/include/algorithms/detail/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@ namespace algorithms::detail {
// Implements the uniform_random_bit_generator concept
class CachedBitGenerator {
public:
using value_type = uint_fast64_t;
using GenFunc = std::function<std::vector<value_type>(size_t /* N */)>;
using result_type = uint_fast64_t;
using GenFunc = std::function<std::vector<result_type>(size_t /* N */)>;
CachedBitGenerator(const GenFunc& gen, const size_t cache_size)
// index starts at the end of the (empty) cache to force an immediate refresh
// on first access
: m_gen{gen}, m_cache(cache_size), m_index{cache_size} {}

value_type operator()() {
result_type operator()() {
if (m_index >= m_cache.size()) {
refresh();
}
return m_cache[m_index++];
}

static constexpr value_type min() { return 0; }
static constexpr value_type max() { return std::numeric_limits<value_type>::max(); }
static constexpr result_type min() { return 0; }
static constexpr result_type max() { return std::numeric_limits<result_type>::max(); }

private:
void refresh() {
Expand All @@ -41,7 +41,7 @@ class CachedBitGenerator {
}

GenFunc m_gen;
std::vector<CachedBitGenerator::value_type> m_cache;
std::vector<CachedBitGenerator::result_type> m_cache;
size_t m_index;
};

Expand Down
2 changes: 1 addition & 1 deletion external/algorithms/core/include/algorithms/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Generator {
// by running off a auto-refreshing cached random sequence.
class RandomSvc : public LoggedService<RandomSvc> {
public:
using value_type = detail::CachedBitGenerator::value_type;
using value_type = detail::CachedBitGenerator::result_type;

Generator generator() { return {m_gen, m_cache_size}; }
// FIXME fix the CMake setup so these are properly found in Gaudi
Expand Down

0 comments on commit 19e82c5

Please sign in to comment.