text
stringlengths 0
2.2M
|
---|
requires 'BSLS_LIBRARYFEATURES_HAS_CPP11_TUPLE'"
|
#endif
|
#ifndef BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES
|
#error "'BSLS_LIBRARYFEATURES_HAS_CPP11_PAIR_PIECEWISE_CONSTRUCTOR' \
|
requires 'BSLS_COMPILERFEATURES_SUPPORT_VARIADIC_TEMPLATES'"
|
#endif
|
#endif
|
static const bool
|
u_BSLS_LIBRARYFEATURES_HAS_CPP11_PAIR_PIECEWISE_CONSTRUCTOR_defined
|
=
|
#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_PAIR_PIECEWISE_CONSTRUCTOR)
|
true;
|
#else
|
false;
|
#endif
|
// case 2
|
#if defined(BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY) || \
|
defined(BSLS_LIBRARYFEATURES_HAS_CPP11_BASELINE_LIBRARY_FORCE)
|
// ----------------------------------------
|
// class SimpleUniformRandomNumberGenerator
|
// ----------------------------------------
|
class SimpleUniformRandomNumberGenerator {
|
// This class defines a simple, easily tested uniform random number
|
// generator that can be validly used as the third argument to the
|
// 'native_std::shuffle' function in the 'useCpp11Algorithms()' test
|
// function.
|
public:
|
// TYPES
|
typedef unsigned result_type;
|
// Alias for the type of the values returned by this class.
|
// CLASS METHODS
|
static BSLS_KEYWORD_CONSTEXPR unsigned min();
|
// Return 0, the smallest value returned by 'operator()'.
|
static BSLS_KEYWORD_CONSTEXPR unsigned max();
|
// Return the largest value *potentially* returned by 'operator()'.
|
// The C++ standard requires that this returned value be greater
|
// than the value returned by the 'min' method; consequentally,
|
// this method returns 1 even though 'operator()(void)' always
|
// returns 0.
|
// CREATORS
|
//! SimpleUniformRandomNumberGenerator() = default;
|
// Create an 'SimpleUniformRandomNumberGenerator' object.
|
//! ~SimpleUniformRandomNumberGenerator() = default;
|
// Destroy this 'SimpleUniformRandomNumberGenerator' object.
|
// ACCESSORS
|
unsigned operator()(void) const;
|
// Return the next value from this 'SimpleUniformNumberGenerator'
|
// object. For this generator, that value is always 0.
|
};
|
// ========================================
|
// class SimpleUniformRandomNumberGenerator
|
// ========================================
|
// CLASS METHODS
|
BSLS_KEYWORD_CONSTEXPR unsigned SimpleUniformRandomNumberGenerator::min()
|
{
|
return 0;
|
}
|
BSLS_KEYWORD_CONSTEXPR unsigned SimpleUniformRandomNumberGenerator::max()
|
{
|
return 1;
|
}
|
unsigned SimpleUniformRandomNumberGenerator::operator()(void) const
|
{
|
return 0;
|
}
|
static void testSimpleUniformRandomNumberGenerator()
|
{
|
ASSERT(SimpleUniformRandomNumberGenerator::min()
|
< SimpleUniformRandomNumberGenerator::max());
|
ASSERT(0 == SimpleUniformRandomNumberGenerator::min());
|
ASSERT(1 == SimpleUniformRandomNumberGenerator::max());
|
SimpleUniformRandomNumberGenerator surng;
|
ASSERT(0 == surng());
|
ASSERT(0 == surng());
|
ASSERT(0 == surng());
|
ASSERT(0 == surng());
|
};
|
#include <algorithm>
|
#include <ios>
|
#include <memory> // for 'uninitialized_copy_n'
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.