---
name: "std::philox_engine"
section: "3"
platform: "linux"
package: "gcc"
version: "16.2.1+r23+gd564253eb6c8-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/std::philox_engine"
---

# std::philox\_engine(3)

A discrete pseudorandom number generator with weak cryptographic properties.

## NAME

std::philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \> - A discrete pseudorandom number generator with weak cryptographic properties.

## SYNOPSIS

\#include \<random\>

### Public Types

using **result\_type**\

### Public Member Functions

template\<typename \_Sseq\> **philox\_engine** (\_Sseq &\_\_q)\
 seed sequence constructor for philox\_engine  **philox\_engine** (result\_type \_\_value)\
 void **discard** (unsigned long long \_\_z)\
 discards \_\_z numbers  result\_type **operator()** ()\
 outputs a single w-bit number and handles state advancement  template\<typename \_Sseq\> \
 requires \_\_is\_seed\_seq\<\_Sseq\>void **seed** (\_Sseq &\_\_q)"\
 seeds philox\_engine by seed sequence  void **seed** (result\_type \_\_value=default\_seed)\
 void **set\_counter** (const **array**\< result\_type, \_\_n \> &\_\_counter)\
 sets the internal counter *cleartext"*

### Static Public Member Functions

static constexpr result\_type **max** ()\
 The maximum value that this engine can return.  static constexpr result\_type **min** ()\
 The minimum value that this engine can return.

### Static Public Attributes

static constexpr result\_type **default\_seed**\
 static constexpr **array**\< result\_type, \_\_n/2 \> **multipliers**\
 static constexpr **array**\< result\_type, \_\_n/2 \> **round\_consts**\
 static constexpr size\_t **round\_count**\
 static constexpr size\_t **word\_count**\
 static constexpr size\_t **word\_size**\

### Friends

template\<typename \_CharT, typename \_Traits\> **basic\_ostream**\< \_CharT, \_Traits \> & **operator\<\<** (**basic\_ostream**\< \_CharT, \_Traits \> &\_\_os, const philox\_engine &\_\_x)\
 outputs the state of the generator  bool **operator==** (const philox\_engine &, const philox\_engine &)=default\
 compares two philox\_engine objects  template\<typename \_CharT, typename \_Traits\> **basic\_istream**\< \_CharT, \_Traits \> & **operator\>\>** (**basic\_istream**\< \_CharT, \_Traits \> &\_\_is, philox\_engine &\_\_x)\
 takes input to set the state of the philox\_engine object

## Detailed Description

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\>

class std::philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \>"A discrete pseudorandom number generator with weak cryptographic properties.

This algorithm was designed to be used for highly parallel random number generation, and is capable of immensely long periods. It provides "Crush-resistance", denoting an ability to pass the TestU01 Suite's "Big Crush" test, demonstrating significant apparent entropy.

It is not intended for cryptographic use and should not be used for such, despite being based on cryptographic primitives.

The typedefs philox4x32 and philox4x64 are provided as suitable defaults for most use cases, providing high-quality random numbers with reasonable performance.

This algorithm was created by John Salmon, Mark Moraes, Ron Dror, and David Shaw as a product of D.E. Shaw Research.

**Template Parameters**

*\_\_w* Word size \
 *\_\_n* Buffer size \
 *\_\_r* Rounds \
 *\_\_consts* Multiplication and round constant pack, ordered as M\_{0}, C\_{0}, M\_{1}, C\_{1}, ... , M\_{N/2-1}, C\_{N/2-1}

**Since**

C++26

## Constructor & Destructor Documentation

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\> template\<typename \_Sseq\> std::philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \>::philox\_engine (\_Sseq & \_\_q) \[inline\], \[explicit\]

seed sequence constructor for philox\_engine

**Parameters**

*\_\_q* the seed sequence

## Member Function Documentation

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\> void std::philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \>::discard (unsigned long long \_\_z) \[inline\]

discards \_\_z numbers

**Parameters**

*\_\_z* number of iterations to discard

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\> constexpr result\_type std::philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \>::max () \[inline\], \[static\], \[constexpr\]

The maximum value that this engine can return.

Referenced by **std::philox\_engine\< uint\_fast32\_t, 32, 4, 10, 0xCD9E8D57, 0x9E3779B9, 0xD2511F53, 0xBB67AE85 \>::operator\>\>**, and **std::philox\_engine\< uint\_fast32\_t, 32, 4, 10, 0xCD9E8D57, 0x9E3779B9, 0xD2511F53, 0xBB67AE85 \>::set\_counter()**.

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\> constexpr result\_type std::philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \>::min () \[inline\], \[static\], \[constexpr\]

The minimum value that this engine can return.

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\> result\_type std::philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \>::operator() () \[inline\]

outputs a single w-bit number and handles state advancement

**Returns**

return\_type

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\>

requires \_\_is\_seed\_seq\<\_Sseq\>template\<typename \_Sseq\> \
 requires \_\_is\_seed\_seq\<\_Sseq\>void **std::philox\_engine**\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \>::seed (\_Sseq & \_\_q)"

seeds philox\_engine by seed sequence

**Parameters**

*\_\_q* the seed sequence

References **std::max()**.

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\> void std::philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \>::set\_counter (const array\< result\_type, \_\_n \> & \_\_counter) \[inline\]

sets the internal counter "cleartext"

**Parameters**

*\_\_counter* std::array of len N

## Friends And Related Symbol Documentation

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\> template\<typename \_CharT, typename \_Traits\> basic\_ostream\< \_CharT, \_Traits \> & operator\<\< (basic\_ostream\< \_CharT, \_Traits \> & \_\_os, const philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \> & \_\_x) \[friend\]

outputs the state of the generator

**Parameters**

*\_\_os* An output stream. \
 *\_\_x* A philox\_engine object reference

**Returns**

the state of the Philox Engine in \_\_os

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\> bool operator== (const philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \> & , const philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \> & ) \[friend\]

compares two philox\_engine objects

**Returns**

true if the objects will produce an identical stream, false otherwise

### template\<typename \_UIntType, size\_t \_\_w, size\_t \_\_n, size\_t \_\_r, \_UIntType... \_\_consts\> template\<typename \_CharT, typename \_Traits\> basic\_istream\< \_CharT, \_Traits \> & operator\>\> (basic\_istream\< \_CharT, \_Traits \> & \_\_is, philox\_engine\< \_UIntType, \_\_w, \_\_n, \_\_r, \_\_consts \> & \_\_x) \[friend\]

takes input to set the state of the philox\_engine object

**Parameters**

*\_\_is* An input stream. \
 *\_\_x* A philox\_engine object reference

**Returns**

philox\_engine object is set with values from instream

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
