-
Notifications
You must be signed in to change notification settings - Fork 1.6k
<random>: Remove non-Standard inheritance from piecewise distributions
#6032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
<random>: Remove non-Standard inheritance from piecewise distributions
#6032
Conversation
tests/std/tests/GH_001600_random_inheritance/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_001600_random_inheritance/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_001600_random_inheritance/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
tests/std/tests/GH_001600_random_inheritance/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
|
Thank you, this is great!! 😻 I pushed minor changes. Importantly, I manually compared old vs. new for debug/release x64/x86, verifying not only the #include <print>
#include <random>
#include <string_view>
using namespace std;
template <typename T>
void test(const string_view name) {
println("sizeof({}): {}", name, sizeof(T));
println("alignof({}): {}", name, alignof(T));
}
int main() {
#ifdef _DEBUG
println("Debug; {}-bit; _MSVC_STL_UPDATE: {}", sizeof(void*) * 8, _MSVC_STL_UPDATE);
#else
println("Release; {}-bit; _MSVC_STL_UPDATE: {}", sizeof(void*) * 8, _MSVC_STL_UPDATE);
#endif
test<piecewise_constant_distribution<float>>("piecewise_constant_distribution<float>");
test<piecewise_constant_distribution<double>>("piecewise_constant_distribution<double>");
test<piecewise_constant_distribution<float>::param_type>("piecewise_constant_distribution<float>::param_type");
test<piecewise_constant_distribution<double>::param_type>("piecewise_constant_distribution<double>::param_type");
test<piecewise_linear_distribution<float>>("piecewise_linear_distribution<float>");
test<piecewise_linear_distribution<double>>("piecewise_linear_distribution<double>");
test<piecewise_linear_distribution<float>::param_type>("piecewise_linear_distribution<float>::param_type");
test<piecewise_linear_distribution<double>::param_type>("piecewise_linear_distribution<double>::param_type");
}
struct Meow1 : piecewise_constant_distribution<float> {};
struct Meow2 : piecewise_constant_distribution<double> {};
struct Meow3 : piecewise_constant_distribution<float>::param_type {};
struct Meow4 : piecewise_constant_distribution<double>::param_type {};
struct Meow5 : piecewise_linear_distribution<float> {};
struct Meow6 : piecewise_linear_distribution<double> {};
struct Meow7 : piecewise_linear_distribution<float>::param_type {};
struct Meow8 : piecewise_linear_distribution<double>::param_type {}; |
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
By changing the
discrete_distribution<size_t>base class subobjects to leading member subobjects. This doesn't change layout of thepiecewise_{constant,linear}_distributionobjects as said in the comments. Also do this for theirparam_type.This results in API breakages but is probably safe for ABI.
Fixes #1600.