Title
Random number engine traits
Status
nad
Section
[rand.synopsis][tr.rand.synopsis]
Submitter
Walter Brown

Created on 2005-07-03.00:00:00 last changed 164 months ago

Messages

Date: 2010-10-21.18:28:33

Rationale:

Recommend NAD, N1932, N2111 covers this. Already in WP.

Date: 2010-10-21.18:28:33

[ Berlin: Walter: While useful for implementation per TR1, N1932 has no need for this feature. Recommend close as NAD. ]

Date: 2005-07-03.00:00:00

To accompany the concept of a pseudo-random number engine as defined in Table 17, we propose and recommend an adjunct template, engine_traits, to be declared in [tr.rand.synopsis] as:

template< class PSRE >
class engine_traits;

This template's primary purpose would be as an aid to generic programming involving pseudo-random number engines. Given only the facilities described in tr1, it would be very difficult to produce any algorithms involving the notion of a generic engine. The intent of this proposal is to provide, via engine_traits<>, sufficient descriptive information to allow an algorithm to employ a pseudo-random number engine without regard to its exact type, i.e., as a template parameter.

For example, today it is not possible to write an efficient generic function that requires any specific number of random bits. More specifically, consider a cryptographic application that internally needs 256 bits of randomness per call:

template< class Eng, class InIter, class OutIter >
void crypto( Eng& e, InIter in, OutIter out );

Without knowning the number of bits of randomness produced per call to a provided engine, the algorithm has no means of determining how many times to call the engine.

In a new section [tr.rand.eng.traits], we proposed to define the engine_traits template as:

template< class PSRE >
class engine_traits
{
  static  std::size_t  bits_of_randomness = 0u;
  static  std::string  name()  { return "unknown_engine"; }
  // TODO: other traits here
};

Further, each engine described in [tr.rand.engine] would be accompanied by a complete specialization of this new engine_traits template.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg2911
2010-10-21 18:28:33adminsetmessages: + msg2910
2005-07-03 00:00:00admincreate