Use if constexpr almost everywhere and cleanup type traits#3240
Use if constexpr almost everywhere and cleanup type traits#3240SteveBronder merged 10 commits intodevelopfrom
if constexpr almost everywhere and cleanup type traits#3240Conversation
…' into fix/constexpr-probs
syclik
left a comment
There was a problem hiding this comment.
@SteveBronder: amazing! It is much easier to read with your changes.
I added a couple of comments. I think the only real one to answer is what's up with the compiler flags? Was that intentional?
And it didn't pass some of the CI tests. Once that's all good, I think we merge!
| if (include_summand<propto, T_y, T_dof>::value && nu_ref != (k + 1)) { | ||
| lp += 0.5 * (nu_ref - k - 1.0) * log_determinant_ldlt(ldlt_W); | ||
| if constexpr (include_summand<propto, T_y, T_dof>::value) { | ||
| if (nu_ref != (k + 1)) { |
|
@syclik thanks!
This is all happening so that we can finally do #3190 and get rid of one of the odder template tricks we had to do in C++14 |
Jenkins Console Log Machine informationNo LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focalCPU: G++: Clang: |
|
@WardBrian @syclik good to merge? |
|
@SteveBronder, it's good to go! |
Summary
This PR does two main things which are mostly just a series of clever greps
ifwith only constexpr evaluated conditionals withif constexpris_autodiff_vinstead of!is_constant<>::valueI think
is_any_autodiffis way easier to read then!is_all_constantTests
No new tests
Side Effects
Previously
is_autodiffonly passed for scalars. But now we have anis_autodiff_scalarthat only checks if the type is a scalarfvarorvarandis_autodiffwill return a value oftruefor any type whosescalar_typeis an autodiff type. This should slightly decrease compile times since now the compiler knows it does not need to go through certain paths and so will never generate anything for the paths we do not go down.Release notes
Replace standard
ifstatements withif constexprwhere posssible.Checklist
Copyright holder: (fill in copyright holder information)
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