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.
The error is because you need a converting constructor that can be used to construct
Alloc<U>
fromAlloc<T>
and vice versa. This adds it.The other requirements for an allocator type are
value_type
,allocate
anddeallocate
, andoperator==
which can both come from thestd::allocator
base class.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 didn't.
To rebind an allocator you need to be able to determine the rebound type, and construct an instance of the rebound type from the original type. With the missing
rebind
the rebound type isstd::allocator<U>
and that can be constructed from asecure_allocator_t<T>
(via slicing). But that's broken.With the new rebind member the rebound type is correct:
secure_allocator_t<U>
. But you can't construct that fromsecure_allocator_t<T>
. So you need to add a converting constructor, and then you also need a user-declared default constructor.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.
Thank you! Taken default constructor and conversion constructor definitions from the non-no-op variant as well. I think it is equivalent to the definition you suggested.