本文介绍了什么是获取C ++ 0x随机数生成器的状态的标准方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图学习新的C ++ 0x方法到随机数生成器(26.5),并实现在C ++ 0x兼容的随机数字引擎(26.5.1.4)。

I am trying to learn the new C++0x approach to random number generators (26.5), and implement at C++0x-compliant random number engine (26.5.1.4).

标准详细介绍了种子序列所需的接口,以及如何将它们传递给构造函数或引擎的 seed 函数。

The standard goes into detail on the required interface for seed sequences, and how they can be passed to the constructor or seed functions of engines.

但是,我找不到任何标准接口来从引擎创建或生成种子序列,从而获得其内部状态。有没有一个?或者只能通过拷贝构造/分配或复制初始种子序列在引擎之间复制状态?

However, I cannot find any standard interface to create or generate a seed sequence from an engine, thereby getting its internal state. Is there one? Or can states only be copied between engines via copy-construction/assignment or copying the initial seed sequence?

如果不可能,任何人都知道原理是什么

If it's not possible, does anyone know what the rationale is (if any) for not providing such an interface?

推荐答案

没有用于从引擎状态生成种子或种子序列的API。然而,发动机的状态可以流入流,并从流中提取。而引擎的状态是EqualityComparable到另一个引擎的状态(对于同类型的引擎)。

There is no API for generating a seed or seed sequence from an engine's state. However the engine's state can be streamed into an istream, and extracted from an ostream. And the engine's state is EqualityComparable to another engine's state (for same-type engines).

可以检查通过流引擎到它生成的istream。但是,istream的格式未指定。

One might inspect the istream generated by streaming an engine to it. However the format of that istream is unspecified.

这篇关于什么是获取C ++ 0x随机数生成器的状态的标准方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 09:51