-
Notifications
You must be signed in to change notification settings - Fork 585
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
Chore: AEAD_Mode can deal with generic containers #3317
Conversation
Codecov ReportPatch coverage:
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more Additional details and impacted files@@ Coverage Diff @@
## master #3317 +/- ##
=======================================
Coverage 88.14% 88.15%
=======================================
Files 617 617
Lines 70356 70353 -3
Branches 6987 6984 -3
=======================================
+ Hits 62016 62020 +4
+ Misses 5399 5394 -5
+ Partials 2941 2939 -2
... and 11 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
Based on a suggestion by @lieser I added an indirection to work around above-mentioned caveat. The protected pure-virtual method Come to think of it, that's exactly what we ended up implementing in #3195. |
0c2309c
to
b1b0ad1
Compare
This changes the public interface of set_associated_data_n() to only take a std::span. The method was introduced just recently, so we hopefully won't bother too many users with that API change. As a result, set_associated_data_n() can be used as the virtual entry point for the AEAD implementations.
Rebased to master after one of yesterday's PRs conflicted with it. |
This introduces
AEAD_Mode::set_associated_data(std::span<>)
alongside the ptr-length-overloads. It switches the virtual method to thestd::span<>
overload and adapts the AEAD implementations accordingly. Alsoset_associated_data_vec()
is marked as deprecated as it is just an alias now.Caveat
This might be somewhat a show-stopper for the overload-based introduction of
std::span<>
we had in mind(also affecting #3297, #3294, #3195, #3201). In short: overloads of virtual methods in the base class are not necessarily dispatched to from an object of a derived type. A godbolt says more than a hundred words.Same code for reference:
Frankly, I'm quite surprised that the method dispatch doesn't find the (publicly available) overload in the base class. 😢 One can work around it by explicitly
using Base::method
in the derived class, but that's easy to miss in large refactorings.On the other hand, one could simply use other method names for the
std::span
overloads. But that complicates the public API even more and forces us to come up with new names for established concepts.What a mess! Or am I actually missing something?