From 2fa6ae6f6219150fabc219e3bf7f1f3487e19930 Mon Sep 17 00:00:00 2001
From: Mark Olesen <Mark.Olesen@Germany>
Date: Fri, 20 Jan 2017 21:13:38 +0100
Subject: [PATCH] STYLE: use pre-increment and cbegin/cend form for forAll*
 macros

- no reason to use post-increment in forAll() macro.

- use C++11 cbegin()/cend() method names for forAll*Iter() macros.
  These method names have been in OpenFOAM since 2009 and are also
  used by C++11 containers.

STYLE: nullptr instead of 0 in UList
---
 src/OpenFOAM/containers/Lists/UList/UList.H  | 8 ++++----
 src/OpenFOAM/containers/Lists/UList/UListI.H | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H
index 719df10a0f0..a31416cc737 100644
--- a/src/OpenFOAM/containers/Lists/UList/UList.H
+++ b/src/OpenFOAM/containers/Lists/UList/UList.H
@@ -427,7 +427,7 @@ inline void reverse(UList<T>&);
 // \endcode
 // \sa forAllReverse
 #define forAll(list, i) \
-    for (Foam::label i=0; i<(list).size(); i++)
+    for (Foam::label i=0; i<(list).size(); ++i)
 
 //- Reverse loop across all elements in \a list
 //  \par Usage
@@ -439,7 +439,7 @@ inline void reverse(UList<T>&);
 //  \endcode
 //  \sa forAll
 #define forAllReverse(list, i) \
-    for (Foam::label i=(list).size()-1; i>=0; i--)
+    for (Foam::label i=(list).size()-1; i>=0; --i)
 
 //- Iterate across all elements in the \a container object of type
 //  \a Container.
@@ -472,8 +472,8 @@ inline void reverse(UList<T>&);
 #define forAllConstIter(Container,container,iter)                              \
     for                                                                        \
     (                                                                          \
-        Container::const_iterator iter = (container).begin();                  \
-        iter != (container).end();                                             \
+        Container::const_iterator iter = (container).cbegin();                 \
+        iter != (container).cend();                                            \
         ++iter                                                                 \
     )
 
diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H
index 0e4825c79c8..bd9fe339ebd 100644
--- a/src/OpenFOAM/containers/Lists/UList/UListI.H
+++ b/src/OpenFOAM/containers/Lists/UList/UListI.H
@@ -3,7 +3,7 @@
   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
    \\    /   O peration     |
     \\  /    A nd           | Copyright (C) 2011-2016 OpenFOAM Foundation
-     \\/     M anipulation  | Copyright (C) 2015 OpenCFD Ltd.
+     \\/     M anipulation  | Copyright (C) 2015-2017 OpenCFD Ltd.
 -------------------------------------------------------------------------------
 License
     This file is part of OpenFOAM.
@@ -33,7 +33,7 @@ template<class T>
 inline Foam::UList<T>::UList()
 :
     size_(0),
-    v_(0)
+    v_(nullptr)
 {}
 
 
@@ -321,7 +321,7 @@ inline bool Foam::UList<T>::empty() const
 template<class T>
 inline void Foam::reverse(UList<T>& ul, const label n)
 {
-    for (int i=0; i<n/2; i++)
+    for (int i=0; i<n/2; ++i)
     {
         Swap(ul[i], ul[n-1-i]);
     }
-- 
GitLab