-
-
Notifications
You must be signed in to change notification settings - Fork 187
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
use value_array_or_scalar in distributions #2352
Conversation
…4.1 (tags/RELEASE_600/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup!
I just think that auto&&
warrants some discussion, since it is used everywhere. It is definitely OK, but it is not the only way. Previously we had const auto&
in such cases, however decltype(auto)
would also work. All these have subtle differences, but in this case all work the same. I am leaning slightly towards const auto&
since it is the simplest option that works here. Unless you have a good argument for auto&&
?
ref_type_t<decltype(promote_scalar<double>( | ||
as_array_or_scalar(as_column_vector_or_scalar(n_obs_ref))))> | ||
n_obs_val = promote_scalar<double>( | ||
as_array_or_scalar(as_column_vector_or_scalar(n_obs_ref))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be less code if you do it in two steps, just like it was done before.
ty!
Yeah I was actually having difficulty thinking about this. I went with auto&& since it binds to all the reference types nicely. Though it's not as if we move these later so it provides no real benefit besides letting me be lazy. I'd be fine with const&. Just to sanity check, |
…4.1 (tags/RELEASE_600/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
So do other two options I mentioned. The difference between
Right. As I mentioned all three options work exactly the same. As we don't need to change these variables I'd prefer the const option. |
Would you mind if I used |
I guess that logic makes just as much sense as what I suggested. |
I just like Whenever I see Is there a reason a compiler would have trouble with a |
But on average this pull simplifies the code that came before it, so if this is ready to merge and you prefer |
…4.1 (tags/RELEASE_600/final)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
@t4c1 do you know a reference somewhere I can read about the rules surrounding cont& as the object type? I'm just not sure what to google to read more about how that works If yinz are fine with decltype then I think this is good to go |
Gaaah I wanna say yes and move on with the deserializer but then I went and read about auto a = 1 + 2; // type of a is int
...
decltype(auto) c1 = a; // type of c1 is int, holding a copy of a
decltype(auto) c2 = (a); // type of c2 is int&, an alias of a Ugh what a weird thing. Can we just be plain I keep flipping flopping on this in the most useless way. |
These are used like decltype(auto) x_ref = to_ref(as_value_array_or_scalar(x)) and since |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good
Alright decltype it is. I scanned through this just to make sure everything was in order. There were some leftover things in |
…4.1 (tags/RELEASE_600/final)
Nice! Yeah there's a few other places we could clean up like the glm functions but I wanted to make this PR just the layups that were obvious |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good (previous review got dismissed)
Jenkins Console Log Machine informationProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010CPU: G++: Clang: |
@SteveBronder You may want to look at how "lifetime extension" works. |
Summary
This just tidies up the distributions a little bit by using
as_value_array_or_scalar()
in places we would do things likeSo now it's just
Note
auto&&
here has a different meaning then we normally think. Assigning to anauto&&
type accepts any type as a reference so it can beauto&
,auto&&
, orconst auto&
Tests
No new tests
Side Effects
Release notes
Tidy up distributions
Checklist
Math issue #(issue number)
Copyright holder: Steve Bronder
The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
- Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
- Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
the basic tests are passing
./runTests.py test/unit
)make test-headers
)make test-math-dependencies
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
the new changes are tested