From f112ea2cb2dd7e6a45d0c35c7f514879eb92deb8 Mon Sep 17 00:00:00 2001 From: Chris Dalton Date: Wed, 9 May 2018 13:10:44 -0600 Subject: Support C++11 range-for loops in SkTInternalLList Bug: skia: Change-Id: Iad5e06fac95c5b805f3735c106103e5a07975b5d Reviewed-on: https://skia-review.googlesource.com/127106 Reviewed-by: Robert Phillips Commit-Queue: Chris Dalton --- src/core/SkTInternalLList.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/core') diff --git a/src/core/SkTInternalLList.h b/src/core/SkTInternalLList.h index df06d8a255..2f43f1c1eb 100644 --- a/src/core/SkTInternalLList.h +++ b/src/core/SkTInternalLList.h @@ -250,10 +250,25 @@ public: return fCurr; } + /** + * C++11 range-for interface. + */ + bool operator!=(const Iter& that) { return fCurr != that.fCurr; } + T* operator*() { return this->get(); } + void operator++() { this->next(); } + private: T* fCurr; }; + Iter begin() const { + Iter iter; + iter.init(*this, Iter::kHead_IterStart); + return iter; + } + + Iter end() const { return Iter(); } + #ifdef SK_DEBUG void validate() const { SkASSERT(!fHead == !fTail); -- cgit v1.2.3