From d823646db3e9f72569717dc656e5b2e4d3ce7709 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 29 Aug 2011 17:49:48 +0200 Subject: containers: add C++11-style c{begin,end}() as alias for const{Begin,End}() C++11 adds cbegin()/cend() functions for the same reason Qt has constBegin()/constEnd(). This patch adds these functions to the Qt containers with the same implementation as constBegin()/constEnd(). It also fixes the return types in the documentation of existing constFind() functions (documentation only). C++11 only adds cbegin()/cend() (and crbegin()/crend(), which Qt doesn't have). In particular, it doesn't add cfind(), so I didn't supply these, even though Qt comes with constFind(). This is a forward-port of https://qt.gitorious.org/qt/qt/merge_requests/1365. Change-Id: Ida086b64246b24e25254eafbcb06c8e33388502b Reviewed-by: Olivier Goffart --- src/corelib/tools/qlist.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/tools/qlist.h') diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h index bf6933732c..3d55b3002d 100644 --- a/src/corelib/tools/qlist.h +++ b/src/corelib/tools/qlist.h @@ -262,9 +262,11 @@ public: // stl style inline iterator begin() { detach(); return reinterpret_cast(p.begin()); } inline const_iterator begin() const { return reinterpret_cast(p.begin()); } + inline const_iterator cbegin() const { return reinterpret_cast(p.begin()); } inline const_iterator constBegin() const { return reinterpret_cast(p.begin()); } inline iterator end() { detach(); return reinterpret_cast(p.end()); } inline const_iterator end() const { return reinterpret_cast(p.end()); } + inline const_iterator cend() const { return reinterpret_cast(p.end()); } inline const_iterator constEnd() const { return reinterpret_cast(p.end()); } iterator insert(iterator before, const T &t); iterator erase(iterator pos); -- cgit v1.2.3