OGLplus  (0.59.0) a C++ wrapper for rendering APIs

any_random_engine.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_ANY_RANDOM_ENGINE_HPP
10 #define EAGINE_ANY_RANDOM_ENGINE_HPP
11 
12 #include "callable_ref.hpp"
13 
14 namespace eagine {
15 
18 template <typename Result>
19 class any_random_engine : public callable_ref<Result()> {
20 public:
22  using result_type = Result;
23 
25  template <typename Engine>
26  any_random_engine(Engine& engine) noexcept
27  : callable_ref<Result()>{construct_from, engine}
28  , _min{engine.min()}
29  , _max{engine.max()} {}
30 
32  auto min() const noexcept -> result_type {
33  return _min;
34  }
35 
37  auto max() const noexcept -> result_type {
38  return _max;
39  }
40 
41 private:
42  result_type _min{0};
43  result_type _max{0};
44 };
45 
47 template <typename Engine>
48 any_random_engine(Engine&) -> any_random_engine<typename Engine::result_type>;
49 
50 } // namespace eagine
51 
52 #endif // EAGINE_ANY_RANDOM_ENGINE_HPP
Declaration of class template storing a reference to a callable object.
Definition: callable_ref.hpp:24
any_random_engine(Engine &) -> any_random_engine< typename Engine::result_type >
Deduction guide for any_random_engine.
Common code is placed in this namespace.
Definition: eagine.hpp:21
Type-erasing reference for standard random engine types.
Definition: any_random_engine.hpp:19
Result result_type
Alias for the engine result type.
Definition: any_random_engine.hpp:22
any_random_engine(Engine &engine) noexcept
Constructor initializing reference to the actual engine.
Definition: any_random_engine.hpp:26
auto max() const noexcept -> result_type
The maximal result value.
Definition: any_random_engine.hpp:37
constexpr const construct_from_t construct_from
The construct-from tag-dispatch constant.
Definition: selector.hpp:47
auto min() const noexcept -> result_type
The minimal result value.
Definition: any_random_engine.hpp:32

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).