【发布时间】:2019-02-13 15:42:57
【问题描述】:
我正在试验一个玩具sample 程序:
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{}() });
但是bar总是按顺序包含foo的内容。这是 gcc 实现的问题,还是我只是反复倒霉?
【问题讨论】:
-
@Dukeling 我要的是随机订单,但我没有得到。
-
@Dukeling 啊,谢谢,这才是我真正需要理解的评论。
标签: c++ algorithm dictionary vector random