libstdc++: Consolidate piecewise distribution configuration macros.
C++ standard library simplifies configuration for piecewise distributions by merging related macros.
GCC’s libstdc++ has consolidated configuration defines related to piecewise distributions in the C++ standard library. Previously, separate macros _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS and _GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES were used, leading to non-orthogonal behavior where one could override the other. This change introduces a single macro, _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS, to manage this configuration, simplifying the code and better reflecting the intended behavior of these distribution types.
In Details
This patch refactors the configuration of piecewise distributions in libstdc++. It replaces the orthogonal macros _GLIBCXX_USE_OLD_PIECEWISE_DISTRIBUTIONS (for behavior prior to C++11) and _GLIBCXX_USE_RESULT_TYPE_FOR_PIECEWISE_DENSITIES (for a specific C++11 behavior) with a single macro _GLIBCXX_USE_NEW_PIECEWISE_DISTRIBUTIONS. This simplifies the logic in bits/random.h and bits/random.tcc for piecewise_constant_distribution and piecewise_linear_distribution, ensuring that the correct behavior is selected based on this unified flag. The test suite is updated to reflect this ch…
- piecewise_constant_distribution
- A C++ standard library random number distribution that generates values based on a series of intervals and their associated probabilities.
- piecewise_linear_distribution
- A C++ standard library random number distribution that generates values based on a piecewise linear function representing probabilities over intervals.
- macro
- A predefined constant or set of code that can be substituted into source code before compilation, typically defined using #define in C/C++.