ARROW-6515: [C++] Clean type_traits.h definitions#5885
Closed
fsaintjacques wants to merge 4 commits intoapache:masterfrom
Closed
ARROW-6515: [C++] Clean type_traits.h definitions#5885fsaintjacques wants to merge 4 commits intoapache:masterfrom
fsaintjacques wants to merge 4 commits intoapache:masterfrom
Conversation
The goal of this PR is to uniformize the usage of type traits and pattern matching on static type information. - Introduce `arrow::enable_if_t` since we're still on C++11. This removes a small amount of boilerplate, e.g. `typename (expr)::type`. Refactor most code to use this, except where type_traits was not included. - Major overhaul of `type_traits.h` by exporting a uniformized (as much as I could) aliases, i.e. `is_X_type` and the accompanying `enable_if_X`. - Removed old struct type traits, e.g. `IsSigned...`. - Removed catch-all-visitor method and replaced them with explicits missing visitor. This will help the implementation of new types to error missing implementation at compile time instead of runtime. - Uniformize usage of `enable_if` with methods, by using the return-place form instead of parameter-place (except when in the constructor). - Fixed some missing implementation when trivial.
cdaa360 to
beea0cc
Compare
bkietz
requested changes
Nov 22, 2019
Member
bkietz
left a comment
There was a problem hiding this comment.
This looks like a great clean up, thanks for doing this
| template <typename Enable = Status> | ||
| auto VisitValue(const Scalar& value) -> | ||
| typename std::enable_if<!with_error_status, Enable>::type { | ||
| auto VisitValue(const Scalar& value) -> enable_if_t<!with_error_status, Enable> { |
Member
There was a problem hiding this comment.
The signature is poorly formed: The enabling condition does not depend on a deduced template parameter so SFINAE can't happen. It's probably not disabling what it was intended to disable
Contributor
Author
There was a problem hiding this comment.
Can you check the new version?
wesm
reviewed
Nov 26, 2019
Member
wesm
left a comment
There was a problem hiding this comment.
Definitely a welcome cleanup, thanks for working through this
|
|
||
| template <typename T> | ||
| using is_number_type = std::is_base_of<NumberType, T>; | ||
| // only in C++14 |
Member
There was a problem hiding this comment.
Is there a conflict when compiling with -std=c++14?
Contributor
Author
There was a problem hiding this comment.
There shouldn't because it's in arrow namespace.
This class attribute is used rarely, no point in keeping it for now. I would suggest to add it to `TypeTraits` classes if needed again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The goal of this PR is to uniformize the usage of type traits and pattern matching on static type information.
arrow::enable_if_tsince we're still on C++11. This removes a small amount of boilerplate, e.g.typename (expr)::type. Refactor most code to use this, except where type_traits was not included.type_traits.hby exporting a uniformized (as much as I could) aliases, i.e.is_X_typeand the accompanyingenable_if_X.IsSigned....enable_ifwith methods, by using the return-place form instead of parameter-place (except when in the constructor).