fork download
  1. #include <iostream>
  2. #include <random>
  3.  
  4. class ConstantGenerator
  5. {
  6. public:
  7. ConstantGenerator(double value) : m_value(value) {}
  8. double min() const { return 0.0; }
  9. double max() const { return 1.0; }
  10. double operator()(){ return m_value; }
  11. using result_type = double;
  12. private:
  13. double m_value = 0.0;
  14. };
  15.  
  16. int main()
  17. {
  18. std::normal_distribution<double> dist{10.0, 1.0};
  19. ConstantGenerator gen{0.5};
  20. std::cout << dist(gen);
  21. }
  22.  
Success #stdin #stdout 0s 4480KB
stdin
Standard input is empty
stdout
1.46885