Commit e9f96b25 authored by Mark Olesen's avatar Mark Olesen Committed by Andrew Heather
Browse files

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)
parent de11575e
......@@ -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
......
......@@ -161,7 +161,7 @@ Foam::FixedList<T, N>::clone() const
template<class T, unsigned N>
inline const T*
Foam::FixedList<T, N>::cdata() const
Foam::FixedList<T, N>::cdata() const noexcept
{
return v_;
}
......@@ -169,35 +169,35 @@ Foam::FixedList<T, N>::cdata() const
template<class T, unsigned N>
inline T*
Foam::FixedList<T, N>::data()
Foam::FixedList<T, N>::data() noexcept
{
return v_;
}
template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::first()
inline T& Foam::FixedList<T, N>::first() noexcept
{
return v_[0];
}
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];
}
template<class T, unsigned N>
inline T& Foam::FixedList<T, N>::last()
inline T& Foam::FixedList<T, N>::last() noexcept
{
return v_[N-1];
}
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];
}
......
......@@ -110,10 +110,10 @@ public:
using FixedList<T, 2>::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;
......
......@@ -117,14 +117,14 @@ inline Foam::Pair<T>::Pair(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline const T& Foam::Pair<T>::second() const
inline const T& Foam::Pair<T>::second() const noexcept
{
return last();
}
template<class T>
inline T& Foam::Pair<T>::second()
inline T& Foam::Pair<T>::second() noexcept
{
return last();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment