Differences in <random> from TR1 to C++-0X

Ed Smith-Rowland 3dw4rd@verizon.net
Wed Nov 12 14:32:00 GMT 2008


Greetings,

I was looking over random both in TR1 and C++-0X and it seems, unlike most
other components, the differences between TR1 and std (C++-0X) for random
are rather significant.  Classes were added, removed, and renamed.

Unfortunately, the std (C++-0X) version still uses the old (TR1) names 
for all
relevant classes.

Here is a table of the differences as I could see them:

=============================================================================================================
Old Name                  New Name                         Comments
------------------------  -------------------------------  
-------------------------------------------------
variate_generator           -                              Removed!

linear_congruential       linear_congruential_engine       Renamed!
mersenne_twister          mersenne_twister_engine          Renamed!
subtract_with_carry       subtract_with_carry_engine       Renamed!
subtract_with_carry_01      -                              Removed!
discard_block             discard_block_engine             Renamed!
  -                       independent_bits_engine          Added.
  -                       shuffle_order_engine             Added.
xor_combine               xor_combine_engine               Renamed!

minstd_rand0              minstd_rand0                     Ok.
minstd_rand               minstd_rand                      Ok.
mt19937                   mt19937                          Ok.
  -                       mt19937_64                       Added.
  -                       ranlux24_base                    Added.
  -                       ranlux48_base                    Added.
  -                       ranlux24                         Added.
  -                       ranlux48                         Added.
  -                       knuth_b                          Added.
  -                       default_random_engine            Added.
ranlux3_01                  -                              Removed!
ranlux4_01                  -                              Removed!

random_device             random_device                    Ok.
  -                       seed_seq                         Added.
  -                       generate_canonical               Added.

uniform_int               uniform_int_distribution         Renamed!?!  
uniform_int is done - why not this?
uniform_real              uniform_real_distribution        Renamed!?!  
uniform_real is done - why not this?
bernoulli_distribution    bernoulli_distribution           Ok.
binomial_distribution     binomial_distribution            Ok.
geometric_distribution    geometric_distribution           Ok.
  -                       negative_binomial_distribution   Added.
poisson_distribution      poisson_distribution             Ok.
exponential_distribution  exponential_distribution         Ok.
gamma_distribution        gamma_distribution               Ok.
  -                       weibull_distribution             Added.
  -                       extreme_value_distribution       Added.
normal_distribution       normal_distribution              Ok.
  -                       lognormal_distribution           Added.
  -                       chi_squared_distribution         Added.
  -                       cauchy_distribution              Added.
  -                       fisher_f_distribution            Added.
  -                       student_t_distribution           Added.
  -                       discrete_distribution            Added.
  -                       piecewise_constant_distribution  Added.
  -                       general_pdf_distribution         Added.
=============================================================================================================

It's the errors of *commission* (Removed/Renamed) that I'm worried 
about.  Clearly,
the additions will wait for 4.5.

I think it might be a bad idea to ship 4.4 with extra and/or misnamed 
symbols in std
although I know it's late.  I don't think it would be wise simply to add 
the new
symols as aliases because we would have nonstandard names that we'd wish 
to deprecate.
Best to nip it in the bud.

It seems that a little bit of #ifdeffery would suffice.  Luckily(?) the 
testsuite
for std::random stuff is mostly empty.  Fixing the testcase to check for 
the corrected
types would be useful.

I would be willing to try this if no one else is working on it.  (I 
noticed some activity
on random that might help with some of the examples in Becker's book ;-) )

Ed



More information about the Libstdc++ mailing list