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)
This commit is contained in:
Mark Olesen
2019-10-02 09:34:07 +02:00
committed by Andrew Heather
parent de11575e1e
commit e9f96b25c9
4 changed files with 16 additions and 16 deletions

View File

@ -189,24 +189,24 @@ public:
//- Return a const pointer to the first data element. //- Return a const pointer to the first data element.
// Similar to the STL front() method and the string::data() method // Similar to the STL front() method and the string::data() method
// This can be used (with caution) when interfacing with C code // 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. //- Return a pointer to the first data element.
// Similar to the STL front() method and the string::data() method // Similar to the STL front() method and the string::data() method
// This can be used (with caution) when interfacing with C code // 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] //- The first element of the list, position [0]
inline T& first(); inline T& first() noexcept;
//- The first element of the list, position [0] //- 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] //- 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] //- 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 //- Return the forward circular index, i.e. next index

View File

@ -161,7 +161,7 @@ Foam::FixedList<T, N>::clone() const
template<class T, unsigned N> template<class T, unsigned N>
inline const T* inline const T*
Foam::FixedList<T, N>::cdata() const Foam::FixedList<T, N>::cdata() const noexcept
{ {
return v_; return v_;
} }
@ -169,35 +169,35 @@ Foam::FixedList<T, N>::cdata() const
template<class T, unsigned N> template<class T, unsigned N>
inline T* inline T*
Foam::FixedList<T, N>::data() Foam::FixedList<T, N>::data() noexcept
{ {
return v_; return v_;
} }
template<class T, unsigned N> template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::first() inline T& Foam::FixedList<T, N>::first() noexcept
{ {
return v_[0]; return v_[0];
} }
template<class T, unsigned N> template<class T, unsigned N>
inline const T& Foam::FixedList<T, N>::first() const inline const T& Foam::FixedList<T, N>::first() const noexcept
{ {
return v_[0]; return v_[0];
} }
template<class T, unsigned N> template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::last() inline T& Foam::FixedList<T, N>::last() noexcept
{ {
return v_[N-1]; return v_[N-1];
} }
template<class T, unsigned N> template<class T, unsigned N>
inline const T& Foam::FixedList<T, N>::last() const inline const T& Foam::FixedList<T, N>::last() const noexcept
{ {
return v_[N-1]; return v_[N-1];
} }

View File

@ -110,10 +110,10 @@ public:
using FixedList<T, 2>::last; using FixedList<T, 2>::last;
//- Return second element, which is also the last element //- 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 //- Return second element, which is also the last element
inline T& second(); inline T& second() noexcept;
//- Return other element //- Return other element
inline const T& other(const T& a) const; inline const T& other(const T& a) const;

View File

@ -117,14 +117,14 @@ inline Foam::Pair<T>::Pair(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T> template<class T>
inline const T& Foam::Pair<T>::second() const inline const T& Foam::Pair<T>::second() const noexcept
{ {
return last(); return last();
} }
template<class T> template<class T>
inline T& Foam::Pair<T>::second() inline T& Foam::Pair<T>::second() noexcept
{ {
return last(); return last();
} }