Skip to content

Commit db185f4

Browse files
committed
The C++ <random> version of random_double() no longer depends on <functional> header
1 parent 5f76429 commit db185f4

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Change Log -- Ray Tracing in One Weekend
2727
- Change: First image size changed to 256x256
2828
- Change: Default image sizes changed from 200x100 to 384x216
2929
- Change: Define image aspect ratio up front, then image height from that and the image width
30+
- Change: The C++ `<random>` version of `random_double()` no longer depends on `<functional>` header
3031

3132
### _The Next Week_
3233
- Change: Large rewrite of the `image_texture` class. Now handles image loading too. (#434)

books/RayTracingInOneWeekend.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,15 +1290,12 @@
12901290
If you want to use this, you can obtain a random number with the conditions we need as follows:
12911291

12921292
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ C++
1293-
#include <functional>
12941293
#include <random>
12951294

12961295
inline double random_double() {
12971296
static std::uniform_real_distribution<double> distribution(0.0, 1.0);
12981297
static std::mt19937 generator;
1299-
static std::function<double()> rand_generator =
1300-
std::bind(distribution, generator);
1301-
return rand_generator();
1298+
return generator(distribution);
13021299
}
13031300
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13041301
[Listing [random-double-alt]: <kbd>[rtweekend.h]</kbd> random_double(), alternate implemenation]

0 commit comments

Comments
 (0)