Deprecate KRandom in favor of QRandomGenerator
Open, Needs TriagePublic

Description

In D24985 @apol suggested using KRandom while @anthonyfieroni noted that std::random_shuffle is deprecated and removed in C++17 (which will be available with Qt6). However KRandom::random cannot be used with std::shuffle because it doesn't fulfill the requirements of UniformRandomBitGenerator. Surely there are more places which would benefit from better compatibility to the standard library.

davidre created this task.Nov 6 2019, 9:42 AM

Or maybe some things could be dropped if there is an equivalent feature in the standard.

davidre moved this task from Backlog to Needs Input on the KF6 board.Nov 6 2019, 9:45 AM
mwolff added a subscriber: mwolff.Nov 22 2019, 9:18 AM

KRandom::random should be removed and QRandomGenerator should be used instead. It has a more expressive API and will actually work properly on platforms without a /dev/urandom.

KRandom::random() -> QRandomGenerator::global()->generate()
```

Random string otoh could be kept if needed but should use QRandomGenerator internally

alex renamed this task from KF6 and STL compatibility to Deprecate KRandom in favor of QRandomGenerator.Apr 17 2021, 1:44 PM
alex moved this task from Needs Input to Done on the KF6 board.
alex added a subscriber: alex.

This has been done in Frameworks 5.72