Make contains_std_vector variadic. #999
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This is a small change that reimplements the
contains_std_vector
metafunction with variadic templates. The previous implementation used a helper metafunction,is_std_vector
, but I think it's a little simpler to do that logic directly incontains_std_vector
. So, I've also removedis_std_vector
and its tests (they weren't testing anything very interesting).These changes are along the lines of things we've been discussing on Discourse: https://discourse.mc-stan.org/t/stan-math-library-c-code-modernization-ideas/5293/8.
I didn't go this far in this PR, but the pattern of checking if anything in a parameter pack satisfies some type-level predicate (in this case, if something is a std::vector) presumably comes up a lot, and could be handled in a more general way, e.g. https://gist.github.com/cqfd/aae7a1d0721279e5e1e04ad8a7205d62
Tests
No new tests (in fact, fewer tests). There are a few tests that used to reference
is_std_vector
, which I've tweaked to usecontains_std_vector
(it's variadic, so it handles a single argument likeis_std_vector
just fine).Side Effects
None.
Checklist
Math issue #(issue number)
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/)
[ x] the basic tests are passing
./runTests.py test/unit
)make test-headers
)make doxygen
)make cpplint
)the code is written in idiomatic C++ and changes are documented in the doxygen
[x ] the new changes are tested