Update SkSpan to match the standard more closely

Change-Id: Iba5a9c24a34d5a08618b9182b476121bf6ce5ef9
Reviewed-on: https://skia-review.googlesource.com/139863
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Herb Derby <herb@google.com>
This commit is contained in:
Herb Derby 2018-07-09 13:24:13 -04:00 committed by Skia Commit-Bot
parent d6fbc1bba6
commit d48897b576

View File

@ -24,8 +24,9 @@ template <typename T>
class SkSpan {
public:
SkSpan() : fPtr{nullptr}, fSize{0} {}
SkSpan(T* ptr, size_t size) : fPtr{ptr}, fSize{size} {}
explicit SkSpan(std::vector<T>& v) : fPtr{v.data()}, fSize{v.size()} {}
SkSpan(T* ptr, ptrdiff_t size) : fPtr{ptr}, fSize{size} { SkASSERT(size >= 0); }
explicit SkSpan(std::vector<T>& v) : fPtr{v.data()}, fSize{SkTo<ptrdiff_t>(v.size())} {}
SkSpan(const SkSpan<T>& o) = default;
SkSpan& operator=( const SkSpan& other ) = default;
T& operator [] (ptrdiff_t i) const { return fPtr[i]; }
T* begin() const { return fPtr; }
@ -38,7 +39,7 @@ public:
private:
T* fPtr;
size_t fSize;
ptrdiff_t fSize;
};
struct SkIndexedRunInfo {