Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:UniformRandomBitGenerator(since C++11)

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      A uniform random bit generator is a function object returning unsigned integer values such that each value in the range of possible results has (ideally) equal probability.

      Uniform random bit generators are not intended to be used as random number generators: they are used as the source of random bits (generated in bulk, for efficiency). Any uniform random bit generator may be plugged into anyrandom number distribution in order to obtain a random number (formally, a random variate).

      Contents

      [edit]Requirements

      The typeG satisfiesUniformRandomBitGenerator if

      Giveng, a value of typeG, all following conditions are satisfied:

      • G::result_type is valid, and denotes an unsigned integer type.
      • The following expressions must be valid and have their specified effects:
      (until C++20)
       Expression TypeRequirements
      G::min()G::result_type 
      • Yields the smallest value thatG'soperator() may return. 
      • The result value is strictly less thanG::max().
      • The expression must be a constant expression.
      G::max()G::result_type
      • Yields the largest value thatG'soperator() may return.
      • The result value is strictly greater thanG::min().
      • The expression must be a constant expression.
      g()G::result_type
      • Returns a value in the closed interval[G::min()G::max()].
      • Has amortized constant complexity.

      All following conditions are satisfied:

      (since C++20)

      [edit]Notes

      AllRandomNumberEngines satisfy this requirement.

      [edit]Standard library

      The following standard library facilities expect aUniformRandomBitGenerator type.

      (until C++17)(C++11)
      randomly re-orders elements in a range
      (function template)[edit]
      (C++17)
      selects N random elements from a sequence
      (function template)[edit]
      evenly distributes real values of given precision across[01)
      (function template)[edit]
      produces integer values evenly distributed across a range
      (class template)[edit]
      produces real values evenly distributed across a range
      (class template)[edit]
      all other random number distributions

      The following standard library facilities satisfyUniformRandomBitGenerator without additionally satisfyingRandomNumberEngine:

      non-deterministic random number generator using hardware entropy source
      (class)[edit]

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2154
      (P0898R3)
      C++11it was unclear whetherG::min() andG::max()
      are required to be constant expressions[1]
      required
      1. The time complexity requirement for these expressions were “compile-time” before C++20. The wording is ambiguous, as “compile-time time complexity” can be interpreted as both “can be evaluated in compile-time” and “the time complexity can be determined in compile-time”.

      [edit]See also

      specifies that a type qualifies as a uniform random bit generator
      (concept)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/UniformRandomBitGenerator&oldid=177086"

      [8]ページ先頭

      ©2009-2025 Movatter.jp