Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Function random

boost::unit_test::data::random — Returns an infinite sequence of random numbers.

Synopsis

// In header: <boost/test/data/monomorphic/generators/random.hpp>


monomorphic::generated_by< monomorphic::random_t<> > random();
template<typename SampleType> 
  monomorphic::generated_by< monomorphic::random_t< SampleType > > 
  random(SampleType begin, SampleType end);
template<typename Params> unspecified random(Params const & params);

Description

The following overloads are available:

auto d = random();
auto d = random(begin, end);
auto d = random(params);
  • The first overload uses the default distribution, which is uniform and which elements are double type (the values are in [0, 1) ).

  • The second overload generates numbers in the given interval. The distribution is uniform (in [begin, end) for real numbers, and in [begin, end] for integers). The type of the distribution is deduced from the type of the begin and end parameters.

  • The third overload generates numbers using the named parameter inside params , which are:

    • distribution: the distribution used. In this overload, since the type of the samples cannot be deduced, the samples are of type double and the distribution is uniform real in [0, 1).

    • seed: the seed for generating the values

    • engine: the random number generator engine

The function returns an object that implements the dataset API.

[Note] Note

This function is available only for C++11 capable compilers.


PrevUpHomeNext