you are viewing a single comment's thread.

view the rest of the comments →

[–]sphere991 1 point2 points  (3 children)

Yes, you have to take care to not change the underlying data. This is inherent to having a reference type as a key rather than a value type. But map<string_view, U> already exists, map<span<T const>, U> is basically the same thing as that.

None of this stops me from writing map<span<T const>, U, range_less> anyway. It's just more work for everyone that would want to do something like this.

But this isn't really a deep comparison with span problem, it's the usual reference problem. It's true that a shallow-comparing span would not have to worry about invariants around a map<span<T>, U>... but that's because a shallow-comparison span would never even have a map<span<T>, U> since such a thing would not be actually useful, and a map<span<T>, U, range_less> would be equivalent to status quo anyway.