[libcxx-commits] [libcxx] [libc++] Fix random_shuffle in __cxx03/__algorithm/shuffle.h (PR #155915)

Zibi Sarbinowski via libcxx-commits libcxx-commits at lists.llvm.org
Fri Aug 29 05:37:23 PDT 2025


zibi2 wrote:

> Why does this matter?

Otherwise the following will fail to compile with -std=c++03:

```
#include <algorithm>
#include <vector>

typedef std::vector<int>::iterator Iter;
typedef std::iterator_traits<Iter>::difference_type Diff;
typedef Diff (*RandomNumberGenerator)(Diff);
void f(Iter a1 ,Iter a2 ,RandomNumberGenerator& a3 ){
 return std::random_shuffle<Iter,RandomNumberGenerator>  (a1, a2, a3);
}
```
Expected to compile clean but received the following:
```
r.C:8:11: error: no matching function for call to 'random_shuffle'
    8 |    return std::random_shuffle<Iter,RandomNumberGenerator>  (a1, a2, a3);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...
```

https://github.com/llvm/llvm-project/pull/155915


More information about the libcxx-commits mailing list