<random>: Implement LWG-3519#2208
Conversation
For posterity: VSO-568006 is an EDG bug "Attributes are not accepted on friend definitions inside class templates" template <class T>
struct S {
[[xyz]] friend int f() { return 0; }
};with EDG incorrectly diagnoses: This result is independent of the choice of attribute ( This bug has been fixed in the EDG frontend that powers IntelliSense (for which the STL has test coverage via |
|
Thanks! As #2088 is smaller and has been waiting for review for almost 2 months, I went ahead and reviewed it, pushed changes, and moved it to Final Review. I'd like to merge it first, and then resolve the conflict in your larger PR. |
I went to resolve the merge conflict and found that this PR merges cleanly with |
|
Thanks for checking - I don't think we need an additional test run with the latest state of |
|
I saw that DevCom-1555597 was reported, which appears to involve unguarded occurrences of Line 263 in d8f03cf We might want to convert all existing usage to _NODISCARD_FRIEND in this PR, if that isn't too much of a distraction (however, handling it separately would also be fine).
|
I think that should be a separate PR to avoid swamping this PR's functional change with an ocean of mechanical replacement. (Yes, "swamping with an ocean" - I'll mix all the metaphors I like!) |
I was on the fence, but if @CaseyCarter prefers a separate PR then let's do it that way. |
|
Looks great! 😻 I pushed a trivial style change and a merge with I saw the minor refactorings you applied (e.g. lifting out a repeated call to |
|
@StephanTLavavej Thanks! While I have your attention, would you mind clarifying an ABI point? I pointed out in item (4) of my first comment that I removed the |
|
Yep, that sounds right to me! In general, changes to header-only functions are ABI-safe unless they do things like:
In such cases, renaming the functions (and renaming affected internal classes, in the "changed object state" scenario) restores safety, since that transforms mix-and-match scenarios from the bad case of "old code links to new, incompatible code" to the good case of "old code has Your moved functionality is equivalent to remove-and-add so it's safe. 😸 |
CaseyCarter
left a comment
There was a problem hiding this comment.
I'll go ahead and apply my single suggestion.
|
@CaseyCarter I pushed a commit to fix test failures - |
|
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
|
Ouch, mea culpa. ( |
|
Thanks for implementing this major LWG issue resolution and improving our workaround for CUDA here! 😻 🛠️ 🚀 |
Fixes #2179.
Notes:
[[nodiscard]]and hidden friends), since it comes up much more now. I'm open to a better name, though, maybe_NODISCARD_HIDDEN_FRIEND.subtract_with_carry_engine, even though<random>: Fixes subtract_with_carry_engine io #2088 does too. I'll work with the author of that PR on a patch to resolve the merge conflict._Writeor_Read, so I took the liberty of inlining those.piecewise_meow_distributionwere a bit subtle because of (IMO) a design mistake. They contain twodiscrete_distribution<size_t>::param_typesubobjects, one from the base class and another from their ownparam_typebase classes. As far as I can tell, only the latter is used, so I've tried to make this more clear. (E.g., previouslydiscrete_distribution::_Meowwas a non-static member function that actually meowed itsparam_typeargument. Now it's a member ofparam_typethat meows the object it's called on.)