OctetString as a special case of a Strong<> type#3296
Closed
Conversation
Collaborator
Author
|
Closed as discussed here. |
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.
Conceptually, the class
OctetStringis nothing but a strong type. Just that it is typed out explicitly as a class. Same is true for theSymmetricKeyandInitializationVectoraliases, of course.This is an attempt to replace this class with:
Long story short: It seems that it would take significant effort to keep the API of
OctetStringstable despite it being a (special case) ofStrong<>.My initial idea was to introduce "capabilities" to strong types. For instance
Strong_Capability::XORablewould yield a container type that implementsoperator^andoperator^=(just likeOctetString). That's not a big deal and probably useful regardless of this draft.Another "capability" would be "legacy octet string behaviour" to retrofit (and probably deprecate)
bits_of(),length(),to_string()and maybe more. That's quirky, but doable.Bigger problems come from
OctetString::begin()andOctetString::end()that return raw pointers rather than iterators. By the way: That's the main reasonOctetStringdoes not satisfyconcepts::container(or bind tostd::span<>).I stopped working on that when it got out of hand to get some feedback whether this is actually useful. My feeling is, that
OctetStringand its type aliases are somewhat a historic artifact, right? But if so: at least a migration strategy (for the sake of consistency) would be worth discussing, I find.