Declare the random number generator lambda for std::random_shuffle as a local.

When not building against the C++11 library headers, the compiler cannot
treat the lambda as lvalue. When building against the C++11 library headers, it
is converted to an rvalue.

BUG=chromium:542321
R=mark@chromium.org

Review URL: https://codereview.chromium.org/1406733003 .
This commit is contained in:
Robert Sesek 2015-10-14 16:56:04 -07:00
parent f059c21048
commit 1f1a24cb51

View File

@ -207,9 +207,10 @@ TEST(PruneCrashReports, PruneOrder) {
reports.push_back(temp);
}
// The randomness from std::rand() is not, so use a better rand() instead.
std::random_shuffle(reports.begin(), reports.end(), [](int rand_max) {
const auto random_generator = [](int rand_max) {
return base::RandUint64() % rand_max;
});
};
std::random_shuffle(reports.begin(), reports.end(), random_generator);
std::vector<CrashReportDatabase::Report> pending_reports(
reports.begin(), reports.begin() + 5);
std::vector<CrashReportDatabase::Report> completed_reports(