Simplify and modernize metaprogramming utils #199
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.
My ultimate goal when beginning this PR was to add developer hints in the form of static_asserts to catch missed
SuperTypespecializations (as mentioned in my last PR). I didn't get that far in this PR, but it has some helpful changes anyways. I started by working to understand (and then simplifying if possible) the metaprogramming utilities related to wrapping parametric types (e.g.apply_combination, etc). As a result, the commits in this PR are not all related, but they are all atomic (with one exception), so I can split this up if/as much as you want (or drop the more style based commits).std::is_same_v<T,U>instead ofstd::is_same<T,U>::value, etc). (The README says C++17 is the minimum required, but the CMake configuration actually requires C++20.)RemoveDuplicates,CombineTypes, andDoApplyandForEachTypewere all simplified to avoid or reduce the amount of recursion by using fold expressions.DoApplyandForEachTypein 2ecb670 works without theCombineTypesrefactor.constexpradded to twoifbranches conditioned on a type-trait