Skip to content

algorithms::detail::CachedBitGenerator: make min/max methods static

Dmitry Kalinkin requested to merge pr/CachedBitGenerator_static_methods into main

Fixes a following compilation error:

In file included from external/algorithms/truth/src/MC2SmearedParticle.cpp:4:
In file included from external/algorithms/truth/include/algorithms/truth/MC2SmearedParticle.h:5:
In file included from external/algorithms/core/include/algorithms/random.h:6:
libcxx-11.1.0-dev/include/c++/v1/random:3645:51: error: call to non-static member function without an object argument
    const size_t __logR = __log2<uint64_t, _URNG::max() - _URNG::min() + uint64_t(1)>::value;
                                           ~~~~~~~^~~
libcxx-11.1.0-dev/include/c++/v1/random:3777:18: note: in instantiation of function template specialization 'std::__1::generate_canonical<double, 53, algorithms::detail::CachedBitGenerator>' requested here
        * _VSTD::generate_canonical<_RealType, numeric_limits<_RealType>::digits>(__g)
                 ^
libcxx-11.1.0-dev/include/c++/v1/random:3741:17: note: in instantiation of function template specialization 'std::__1::uniform_real_distribution<double>::operator()<algorithms::detail::CachedBitGenerator>' requested here
        {return (*this)(__g, __p_);}
                ^
libcxx-11.1.0-dev/include/c++/v1/random:4336:19: note: in instantiation of function template specialization 'std::__1::uniform_real_distribution<double>::operator()<algorithms::detail::CachedBitGenerator>' requested here
            __u = _Uni(__g);
                  ^
libcxx-11.1.0-dev/include/c++/v1/random:4275:17: note: in instantiation of function template specialization 'std::__1::normal_distribution<double>::operator()<algorithms::detail::CachedBitGenerator>' requested here
        {return (*this)(__g, __p_);}
                ^
external/algorithms/core/include/algorithms/random.h:52:12: note: in instantiation of function template specialization 'std::__1::normal_distribution<double>::operator()<algorithms::detail::CachedBitGenerator>' requested here
    return d(m_gen);
           ^
external/algorithms/truth/src/MC2SmearedParticle.cpp:33:40: note: in instantiation of function template specialization 'algorithms::Generator::gaussian<double>' requested here
    const auto momentum = pgen * m_rng.gaussian<double>(0., m_smearing.value());
                                       ^
In file included from external/algorithms/truth/src/MC2SmearedParticle.cpp:4:
In file included from external/algorithms/truth/include/algorithms/truth/MC2SmearedParticle.h:5:
In file included from external/algorithms/core/include/algorithms/random.h:6:
libcxx-11.1.0-dev/include/c++/v1/random:3648:57: error: call to non-static member function without an object argument
    const _RealType _Rp = static_cast<_RealType>(_URNG::max() - _URNG::min()) + _RealType(1);
                                                 ~~~~~~~^~~
libcxx-11.1.0-dev/include/c++/v1/random:3650:36: error: call to non-static member function without an object argument
    _RealType _Sp = __g() - _URNG::min();
                            ~~~~~~~^~~
3 errors generated.

Merge request reports