-
Notifications
You must be signed in to change notification settings - Fork 21
Enable -Wconversion warnings to avoid inadvertent lowering conversions #358
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
Just curious, what does setting 'typename T = void' buy?
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.
It declares a template taking a type parameter, which, if omitted from the function call, such as by calling
GetCSRSetter(...)
normally instead of calling itGetCSRSetter<uint64_t>(...)
, defaults that parameter tovoid
. In this use-case we don't actually care about the typeT
-- we simply pass it as a template argument ofmake_dependent<T>(...)
so that the function argument ofmake_dependent()
is delayed evaluation until the template with parameterT
is instantiated. Here are the principles it uses:<...>
arrow brackets at the call site, or defaulted if defaults exist in the template declaration. One of those 3 methods must define every template argument corresponding to each template parameter, or the "template argument deduction" fails.T
is called dependent, and its evaluation and semantic correctness is deferred until the template is actually instantiated with template arguments. It is not fully evaluated or judged for anything beyond syntactic correctness at template definition time.make_dependent<T>( expr )
acts like an identity operation onexpr
, except that it makes the expression dependent onT
so that its evaluation and semantic correctness are delayed until the template with parameterT
is actually instantiated.expr
to have an expression involvingRevCore
which is invalid at template definition time becauseRevCore
is an incomplete type and we don't know about its members yet, only that it has been forward-declared as a class. But when we finally instantiate the CSR template function,RevCore
will be a complete type,T
will be defined by the template instantiation, andmake_dependent<T>(...)
can callRevCore
methods becauseRevCore
is complete by then.RevCore
andRevCSR
can both call methods of each other if one of the class's calls is made dependent on a template parameter and the template is not instantiated until the other class is fully defined. It's analogous to mutually recursive functions. You make a forward declaration of one class, call methods of it in another class which are deferred until template instantiation, and then actually define the class. After both classes are defined, the template can be instantiated. The dependence of expressions on template parameters breaks the circular dependency, even if the actual template argument passed tomake_dependent
does not change its result.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.
See the discussion here, opened by me.
Rev has a lot of circular dependencies that I invented
make_dependent<type1, type2, ...>( expr )
to break circular dependencies.In
RevOpts.cc
make_dependent<decltype( var )>(...)
is used to defer evaluation of an expression until a generic lambda (lambda withauto
parameters)'s type parameters are known at lambda call-time. Generic lambdas create templates "under the hood" which have the same effect of deferring dependent expressions which depend on the type of theauto
parameter's actual argument.