Simplify check for usm allocated vector iterator #1536
Merged
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.
After a hint from @akukanov, it seems there is a simpler approach to the fix provided in #1527.
Instead of specifically avoiding instantiating
std::vector<T>
for typesT
which are not valid, we can merely usestd::decay_t
prior to our USM iterator checks.This will prevent any ill-formed
std::vector
from being instantiated, and also should not damage our ability to detect any valid USM allocatedstd::vector::iterator
.Any
std::vector::iterator
type created from a decayed value type should not match the original iterator type ifstd::decay
has an effect on the value type. Ifstd::decay
has an effect on the value type, then it is not a validstd::vector
.This should fix the problem same issue with simpler code, and not change our behavior.
(There is no need to rush this before the freeze, the result should be identical, this is just cleaner code)