From 7f2b0edc0456db4f02c514dd157a260d741d82b8 Mon Sep 17 00:00:00 2001 From: Nam Hyeon Uk Date: Thu, 7 Apr 2016 14:47:01 +0900 Subject: [PATCH] Vector iterator declaration & initializer list constructor * Vector iterator typedef -> alias declaration * Vector constructor with initializer list * fix indent --- cocos/base/CCVector.h | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/cocos/base/CCVector.h b/cocos/base/CCVector.h index e5568a58be..c40e410cac 100644 --- a/cocos/base/CCVector.h +++ b/cocos/base/CCVector.h @@ -53,14 +53,14 @@ public: // ------------------------------------------ /** Iterator, can be used to loop the Vector. */ - typedef typename std::vector::iterator iterator; + using iterator = typename std::vector::iterator; /** Const iterator, can be used to loop the Vector. */ - typedef typename std::vector::const_iterator const_iterator; - + using const_iterator = typename std::vector::const_iterator; + /** Reversed iterator, can be used to loop the Vector in reverse sequence. */ - typedef typename std::vector::reverse_iterator reverse_iterator; - /** Reversed iterator, can be used to loop the Vector in reverse sequence. */ - typedef typename std::vector::const_reverse_iterator const_reverse_iterator; + using reverse_iterator = typename std::vector::reverse_iterator; + /** Reversed iterator, can be used to loop the Vector in reverse sequence. */ + using const_reverse_iterator = typename std::vector::const_reverse_iterator; /** Returns an iterator pointing the first element of the Vector. */ iterator begin() { return _data.begin(); } @@ -125,6 +125,15 @@ public: reserve(capacity); } + /** Constructor with initializer list. */ + Vector(std::initializer_list list) + { + for (auto& element : list) + { + pushBack(element); + } + } + /** Destructor. */ ~Vector() {