samedi 8 septembre 2018

Why is sample Not Randomly Populating my Vector?

I was experimenting with a toy sample program:

map<int, char> foo { { 1, 'a' }, { 2, 'b' }, { 3, 'c' } };
vector<pair<decltype(foo)::key_type, decltype(foo)::mapped_type>> bar(size(foo));

sample(begin(foo), end(foo), begin(bar), size(foo), mt19937{ random_device{}() });

Live Example

But bar always contains the contents of foo in order. Is this a gcc implementation problem, or am I just repeatedly getting unlucky?




Aucun commentaire:

Enregistrer un commentaire