PR libstdc++/85749 constrain seed sequences for random number engines
authorJonathan Wakely <jwakely@redhat.com>
Tue, 15 May 2018 15:36:46 +0000 (16:36 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Tue, 15 May 2018 15:36:46 +0000 (16:36 +0100)
commit5a7960da41fec497eb4203d71215bcb1077207a9
tree459507cfc4f9ff9bc0b70712e1db9fd0ce037432
parentc3b61fdadd7ffc9ef5c613c2df0ff4edf83ad0fc
PR libstdc++/85749 constrain seed sequences for random number engines

Constrain constructors and member functions of random number engines so
that functions taking seed sequences can only be called with types that
meet the seed sequence requirements.

PR libstdc++/85749
* include/bits/random.h (__detail::__is_seed_seq): New SFINAE helper.
(linear_congruential_engine, mersenne_twister_engine)
(subtract_with_carry_engine, discard_block_engine)
(independent_bits_engine, shuffle_order_engine): Use __is_seed_seq to
constrain function templates taking seed sequences.
* include/bits/random.tcc (linear_congruential_engine::seed(_Sseq&))
(mersenne_twister_engine::seed(_Sseq&))
(subtract_with_carry_engine::seed(_Sseq&)): Change return types to
match declarations.
* include/ext/random (simd_fast_mersenne_twister_engine): Use
__is_seed_seq to constrain function templates taking seed sequences.
* include/ext/random.tcc (simd_fast_mersenne_twister_engine::seed):
Change return type to match declaration.
* testsuite/26_numerics/random/discard_block_engine/cons/seed_seq2.cc:
New.
* testsuite/26_numerics/random/independent_bits_engine/cons/
seed_seq2.cc: New.
* testsuite/26_numerics/random/linear_congruential_engine/cons/
seed_seq2.cc: New.
* testsuite/26_numerics/random/mersenne_twister_engine/cons/
seed_seq2.cc: New.
* testsuite/26_numerics/random/pr60037-neg.cc: Adjust dg-error lineno.
* testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq2.cc:
New.
* testsuite/26_numerics/random/subtract_with_carry_engine/cons/
seed_seq2.cc: New.
* testsuite/ext/random/simd_fast_mersenne_twister_engine/cons/
seed_seq2.cc: New.

From-SVN: r260263
13 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/random.h
libstdc++-v3/include/bits/random.tcc
libstdc++-v3/include/ext/random
libstdc++-v3/include/ext/random.tcc
libstdc++-v3/testsuite/26_numerics/random/discard_block_engine/cons/seed_seq2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/random/independent_bits_engine/cons/seed_seq2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/random/linear_congruential_engine/cons/seed_seq2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/random/mersenne_twister_engine/cons/seed_seq2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/random/pr60037-neg.cc
libstdc++-v3/testsuite/26_numerics/random/shuffle_order_engine/cons/seed_seq2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/26_numerics/random/subtract_with_carry_engine/cons/seed_seq2.cc [new file with mode: 0644]
libstdc++-v3/testsuite/ext/random/simd_fast_mersenne_twister_engine/cons/seed_seq2.cc [new file with mode: 0644]