-
Notifications
You must be signed in to change notification settings - Fork 113
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
Add spec compliant histogram API while supporting legacy extension API #1793
Draft
danhoeflinger
wants to merge
11
commits into
main
Choose a base branch
from
dev/dhoeflin/histogram_API_fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+266
−23
Draft
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c549d52
add spec compliant API while supporting legacy extension API
danhoeflinger c40b3fe
::std -> std
danhoeflinger ba9ece8
adding required extra unused defaulted template param
danhoeflinger a7dab72
restoring formatting only change
danhoeflinger d707788
improving comment language
danhoeflinger fcfaf59
improved enable_if logic
danhoeflinger 1cdfc3f
correct spelling
danhoeflinger c3f87d3
adding testing for extension APIs; minor bugfixes in sequential test …
danhoeflinger 127f2cb
Improve comment about explicit specification of template args
danhoeflinger ce768f5
spelling
danhoeflinger 8e329b9
deprecating APIs, and adding test macro to avoid testing deprecated APIs
danhoeflinger 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 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 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.
I wonder if keeping the old variant of the function available sort of defeats the purpose of adding the new one, as Dan wrote in a comment to the specification PR:
If this overload is kept under the condition of type not being the same as the iterator value type, it will be selected even for the cases where we would want to have the conversion done only once. If the condition is changed to that of type not being convertible, will the code even work for such types? Or should the condition be for types that are not implicitly convertible to the desired one, while still explicitly convertible?
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.
I need to experiment here a little to see if there is a better check. I think if we check
!std::is_convertible
instead, I think it should still work.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.
Technically, I believe this works with
!std::is_convertible_v
in place of!istd::is_same_v
in that all the cases which build and run before still build and run in the new version as well.However, the unused and defaulted template parameter feels a little more hacky with this version. With the
!std::is_same_v
version, we know that the only time the spec compliant signature is picked, the types are the same, so doing this conversion is a no-op. Alternately, with!std::is_convertible_v
, if someone explicitly lists out their parameter list, including a_ValueType
which is convertible but not the same as the input iterator value type to match the old signature, we would still pick the new spec compliant overload and do the conversion.I have an improved version in a sandbox godbolt which adds a (sigh) 4th overload, but manages to remove the hacky unused and defaulted template parameter from the spec compliant signature.
This version breaks up the extension overloads into two signatures:
type not convertible to input iterator value type
This is basically what we have here, but checking
!std::is_convertible_v
Explicit template list
This makes the 4th template argument non-deducable, but has 5th and 6th template arguments to represent the types of the two boundary limit parameters
I'll get an commit in to update this PR with what it would look like tomorrow, its better, but I think I still prefer 1a or 1b.
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.
I've updated the code to implement the improved logic for supporting the extension API cases, and added tests to check these overloads specifically.