I have inherited a C++ project that was written in 2014 and indeed compiles with GCC 4.8. In a particular file, several classes currently found in the <random>
header of C++ standard library are instantiated. These include mt19937
, random_device
, uniform_real_distribution
, and normal_distribution
.
When I compile this file with GCC 7.3, I get an error saying that these classes are not defined in the std
namespace. This error (obviously) goes away when I include <random>
.
My question is why this error does not happen in GCC 4.8? Were these classes previously found under a different header?
Standard headers may include other headers. This can be useful when they share an implementation. However, these things can change over time, e.g. when the common parts are refactored to a third (internal) header file.
Since we don't know exactly how <random>
got included indirectly with GCC4.8, we can't be absolutely positive about what happened, but it is not surprising.