[libcxx-commits] [PATCH] D92255: [libc++] [P0202] constexpr set_union, set_difference, set_symmetric_difference, merge

Zoe Carver via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Sat Nov 28 13:33:48 PST 2020


zoecarver added inline comments.


================
Comment at: libcxx/test/std/algorithms/alg.sorting/alg.merge/merge.pass.cpp:75
         ic[i] = i;
     std::shuffle(ic, ic+2*N, randomness);
     std::copy(ic, ic+N, ia);
----------------
Quuxplusone wrote:
> @zoecarver: "What about merge.pass.cpp isn't constexpr-friendly?" The use of std::shuffle here, and also perhaps `new` and `delete`. ;)
OK, let's make this a fixed-size array so we don't have the new/delete. I don't think there's any reason we need this test to run on `100000` elements. 

We could simply replace `std::shuffle` with:
```
for (auto i = n-1; i > 0; --i)
  swap(ic[i], ic[randomness() % (i+1)]);
```

I know this requires a bit of test modification, but I think this is the way we should try to do these tests.

Or, better yet, we could add a test utility random engine that is constexpr.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92255/new/

https://reviews.llvm.org/D92255



More information about the libcxx-commits mailing list