From e9f96b25c98a318ce20832b35f2650cf6be3510b Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 2 Oct 2019 09:34:07 +0200 Subject: [PATCH] STYLE: mark FixedList data(), first(), last() as noexcept - since a zero-sized FixedList is disallowed, the accessors to the first/last elements are always known. This allows Pair second() to be noexcept as well (as per Tuple2) --- src/OpenFOAM/containers/Lists/FixedList/FixedList.H | 12 ++++++------ src/OpenFOAM/containers/Lists/FixedList/FixedListI.H | 12 ++++++------ src/OpenFOAM/primitives/Pair/Pair.H | 4 ++-- src/OpenFOAM/primitives/Pair/PairI.H | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index ca5f1d0aab..64f2f8288b 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -189,24 +189,24 @@ public: //- Return a const pointer to the first data element. // Similar to the STL front() method and the string::data() method // This can be used (with caution) when interfacing with C code - inline const T* cdata() const; + inline const T* cdata() const noexcept; //- Return a pointer to the first data element. // Similar to the STL front() method and the string::data() method // This can be used (with caution) when interfacing with C code - inline T* data(); + inline T* data() noexcept; //- The first element of the list, position [0] - inline T& first(); + inline T& first() noexcept; //- The first element of the list, position [0] - inline const T& first() const; + inline const T& first() const noexcept; //- The last element of the list, position [N-1] - inline T& last(); + inline T& last() noexcept; //- The last element of the list, position [N-1] - inline const T& last() const; + inline const T& last() const noexcept; //- Return the forward circular index, i.e. next index diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index 6746624ebd..ece9243aa6 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -161,7 +161,7 @@ Foam::FixedList::clone() const template inline const T* -Foam::FixedList::cdata() const +Foam::FixedList::cdata() const noexcept { return v_; } @@ -169,35 +169,35 @@ Foam::FixedList::cdata() const template inline T* -Foam::FixedList::data() +Foam::FixedList::data() noexcept { return v_; } template -inline T& Foam::FixedList::first() +inline T& Foam::FixedList::first() noexcept { return v_[0]; } template -inline const T& Foam::FixedList::first() const +inline const T& Foam::FixedList::first() const noexcept { return v_[0]; } template -inline T& Foam::FixedList::last() +inline T& Foam::FixedList::last() noexcept { return v_[N-1]; } template -inline const T& Foam::FixedList::last() const +inline const T& Foam::FixedList::last() const noexcept { return v_[N-1]; } diff --git a/src/OpenFOAM/primitives/Pair/Pair.H b/src/OpenFOAM/primitives/Pair/Pair.H index fc8a1f01de..8ac0ca43f2 100644 --- a/src/OpenFOAM/primitives/Pair/Pair.H +++ b/src/OpenFOAM/primitives/Pair/Pair.H @@ -110,10 +110,10 @@ public: using FixedList::last; //- Return second element, which is also the last element - inline const T& second() const; + inline const T& second() const noexcept; //- Return second element, which is also the last element - inline T& second(); + inline T& second() noexcept; //- Return other element inline const T& other(const T& a) const; diff --git a/src/OpenFOAM/primitives/Pair/PairI.H b/src/OpenFOAM/primitives/Pair/PairI.H index de82a7a7e6..9eae799920 100644 --- a/src/OpenFOAM/primitives/Pair/PairI.H +++ b/src/OpenFOAM/primitives/Pair/PairI.H @@ -117,14 +117,14 @@ inline Foam::Pair::Pair(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline const T& Foam::Pair::second() const +inline const T& Foam::Pair::second() const noexcept { return last(); } template -inline T& Foam::Pair::second() +inline T& Foam::Pair::second() noexcept { return last(); }