Share via


xor_combine::xor_combine

Constructs the generator.

xor_combine();
xor_combine(const base1_type& eng1, const base2_type& eng2);
template<class Gen>
   xor_combine(Gen& gen);
   xor_combine(const xor_combine& right);
   xor_combine(xor_combine& right);

Parameters

  • eng1
    The first stored engine object.

  • eng2
    The second stored engine object.

  • Gen
    The type of the seed random engine.

  • gen
    The seed random engine.

  • right
    An xor_combine object.

Remarks

The first constructor constructs an xor_combine object with stored values stored_eng1 and stored_eng2 constructed with their respective default constructors. The second constructor constructs an xor_combine object whose stored value stored_eng1 holds a copy of eng1 and whose stored value stored_eng2 holds a copy of eng2. The third constructor constructs an xor_combine object and calls seed(gen). The fourth and fifth constructors construct an xor_combine object from an xor_combine object.

Example

 

// std_tr1__random__xor_combine_construct.cpp 
// compile with: /EHsc 
#include <random> 
#include <iostream> 
 
typedef std::subtract_with_carry<unsigned int, 
    1 << 24, 10, 24> Myeng1; 
typedef std::linear_congruential<unsigned int, 
    16807, 0, (1U << 31) - 1> Myeng2; 
typedef std::xor_combine<Myeng1, 1, Myeng2, 2> Myceng; 
int main() 
    { 
    Myeng1 eng1; 
    Myeng2 eng2; 
    Myceng ceng; 
    const Myceng::base1_type& base1 = ceng.base1(); // get base engine 
    const Myceng::base2_type& base2 = ceng.base2(); // get base engine 
    Myceng::result_type compval = ceng(); 
 
    compval = compval;  // to quiet "unused" warnings 
    base1.min(); 
    base2.min(); 
 
    std::cout << "S1 == " << Myceng::shift1 << std::endl; 
    std::cout << "S2 == " << Myceng::shift2 << std::endl; 
 
    std::cout << "min == " << ceng.min() << std::endl; 
    std::cout << "max == " << ceng.max() << std::endl; 
 
    ceng.seed(); // reseed base engine 
    std::cout << "a random value == " << ceng() << std::endl; 
    std::cout << "a random value == " << ceng() << std::endl; 
    std::cout << "a random value == " << ceng() << std::endl; 
 
    Myceng ceng2(eng1); // construct with generator 
    ceng2.seed(eng1);  // seed with generator 
 
    return (0); 
    } 
 
S1 == 1
S2 == 2
min == 0
max == 4294967294
a random value == 30142660
a random value == 1118486894
a random value == 2204980952

Requirements

Header: <random>

Namespace: std

See Also

Reference

<random>

xor_combine Class

Other Resources

<random> Members