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

STYLE: mark containers empty() and size() as noexcept

parent 2c11d875
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2011, 2017-2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011, 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2017 OpenFOAM Foundation
......@@ -125,14 +125,15 @@ public:
// Access
//- Return true if a precompiled expression does not exist
inline bool empty() const;
inline bool empty() const noexcept;
//- Return true if a precompiled expression exists
inline bool exists() const;
inline bool exists() const noexcept;
//- The number of capture groups for a non-empty expression
inline unsigned ngroups() const;
// Editing
//- Clear expression.
......@@ -150,6 +151,7 @@ public:
// \return True if the pattern was compiled
bool set(const std::string& pattern, bool ignoreCase=false);
// Matching/Searching
//- Find position within the text.
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -98,15 +98,15 @@ inline Foam::regExpPosix::~regExpPosix()
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
inline bool Foam::regExpPosix::empty() const
inline bool Foam::regExpPosix::empty() const noexcept
{
return !preg_;
}
inline bool Foam::regExpPosix::exists() const
inline bool Foam::regExpPosix::exists() const noexcept
{
return preg_ ? true : false;
return preg_;
}
......
......@@ -283,7 +283,7 @@ public:
//- Number of entries.
inline label size() const noexcept;
//- Return true if the list is empty (ie, size() is zero).
//- True if the list is empty (ie, size() is zero).
inline bool empty() const noexcept;
//- The number of elements that can be stored with reallocating
......
......@@ -233,13 +233,13 @@ public:
// Access
//- The size of the underlying table
inline label capacity() const;
inline label capacity() const noexcept;
//- Return number of elements in table
inline label size() const;
//- The number of elements in table
inline label size() const noexcept;
//- Return true if the hash table is empty
inline bool empty() const;
//- True if the hash table is empty
inline bool empty() const noexcept;
//- Find and return a hashed entry. FatalError if it does not exist.
inline T& at(const Key& key);
......
......@@ -62,8 +62,7 @@ struct HashTableCore
static label canonicalSize(const label requested_size);
//- Construct null
HashTableCore()
{}
HashTableCore() = default;
//- Define template name and debug
ClassName("HashTable");
......@@ -105,8 +104,8 @@ struct HashTableCore
inline const_iterator_pair(const TableType& tbl);
inline label size() const;
inline bool empty() const;
label size() const noexcept { return size_; }
bool empty() const noexcept { return !size_; }
inline IteratorType begin() const;
inline IteratorType cbegin() const;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -73,22 +73,6 @@ inline Foam::HashTableCore::const_iterator_pair<IteratorType, TableType>
{}
template<class IteratorType, class TableType>
inline Foam::label
Foam::HashTableCore::const_iterator_pair<IteratorType, TableType>::size() const
{
return size_;
}
template<class IteratorType, class TableType>
inline bool
Foam::HashTableCore::const_iterator_pair<IteratorType, TableType>::empty() const
{
return !size_;
}
template<class IteratorType, class TableType>
inline IteratorType Foam::HashTableCore::const_iterator_pair
<
......
......@@ -41,21 +41,21 @@ Foam::HashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, class Key, class Hash>
inline Foam::label Foam::HashTable<T, Key, Hash>::capacity() const
inline Foam::label Foam::HashTable<T, Key, Hash>::capacity() const noexcept
{
return capacity_;
}
template<class T, class Key, class Hash>
inline Foam::label Foam::HashTable<T, Key, Hash>::size() const
inline Foam::label Foam::HashTable<T, Key, Hash>::size() const noexcept
{
return size_;
}
template<class T, class Key, class Hash>
inline bool Foam::HashTable<T, Key, Hash>::empty() const
inline bool Foam::HashTable<T, Key, Hash>::empty() const noexcept
{
return !size_;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
......@@ -83,11 +83,11 @@ public:
// Access
//- Return the number of elements in the list
inline label size() const;
//- The number of elements in the list
inline label size() const noexcept;
//- Return true if the list is empty (ie, size() is zero).
inline bool empty() const;
//- True if the list is empty (ie, size() is zero).
inline bool empty() const noexcept;
inline const UList<T>& posList() const;
inline const UList<T>& negList() const;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
......@@ -74,14 +74,14 @@ inline Foam::BiIndirectList<T>::BiIndirectList
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T>
inline Foam::label Foam::BiIndirectList<T>::size() const
inline Foam::label Foam::BiIndirectList<T>::size() const noexcept
{
return addressing_.size();
}
template<class T>
inline bool Foam::BiIndirectList<T>::empty() const
inline bool Foam::BiIndirectList<T>::empty() const noexcept
{
return addressing_.empty();
}
......
......@@ -153,11 +153,11 @@ public:
// Member Functions
//- Return number of elements in list
inline label size() const;
//- The number of elements in list
inline label size() const noexcept;
//- Return true if the list is empty
inline bool empty() const;
//- True if the list is empty
inline bool empty() const noexcept;
//- Return first entry
inline link* first();
......
......@@ -110,13 +110,13 @@ inline void Foam::DLListBase::link::deregister()
}
inline Foam::label Foam::DLListBase::size() const
inline Foam::label Foam::DLListBase::size() const noexcept
{
return size_;
}
inline bool Foam::DLListBase::empty() const
inline bool Foam::DLListBase::empty() const noexcept
{
return !size_;
}
......
......@@ -141,11 +141,11 @@ public:
// Member Functions
//- Return number of elements in list
inline label size() const;
//- The number of elements in list
inline label size() const noexcept;
//- Return true if the list is empty
inline bool empty() const;
//- True if the list is empty
inline bool empty() const noexcept;
//- Return first entry
inline link* first();
......
......@@ -69,13 +69,13 @@ inline IteratorType Foam::SLListBase::iterator_last() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::label Foam::SLListBase::size() const
inline Foam::label Foam::SLListBase::size() const noexcept
{
return size_;
}
inline bool Foam::SLListBase::empty() const
inline bool Foam::SLListBase::empty() const noexcept
{
return !size_;
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
......@@ -141,11 +141,11 @@ public:
// Access
//- Return the primary size, i.e. the number of rows
inline label size() const;
//- The primary size (the number of rows)
inline label size() const noexcept;
//- Return true if the number of rows is zero
inline bool empty() const;
//- True if the number of rows is zero
inline bool empty() const noexcept;
//- Return the offset table (= size()+1)
inline const List<label>& offsets() const;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2011-2016 OpenFOAM Foundation
......@@ -118,14 +118,14 @@ Foam::CompactListList<T, Container>::null()
template<class T, class Container>
inline Foam::label Foam::CompactListList<T, Container>::size() const
inline Foam::label Foam::CompactListList<T, Container>::size() const noexcept
{
return size_;
}
template<class T, class Container>
inline bool Foam::CompactListList<T, Container>::empty() const
inline bool Foam::CompactListList<T, Container>::empty() const noexcept
{
return !size_;
}
......
......@@ -82,12 +82,11 @@ class DynamicList
{
static_assert(SizeMin > 0, "Invalid min size parameter");
// Private data
// Private Data
//- The capacity (allocated size) of the underlying list.
label capacity_;
private:
// Private Member Functions
......@@ -97,7 +96,6 @@ private:
//- Subset elements in range
label subsetElements(const labelRange& slice);
protected:
// Protected Member Functions
......@@ -174,13 +172,13 @@ public:
// Member Functions
// Access
// Access
//- Normal lower capacity limit - the SizeMin template parameter
inline label min_size() const;
static constexpr label min_size() noexcept { return SizeMin; }
//- Size of the underlying storage.
inline label capacity() const;
inline label capacity() const noexcept;
// Edit
......
......@@ -220,14 +220,7 @@ inline Foam::DynamicList<T, SizeMin>::DynamicList
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, int SizeMin>
inline Foam::label Foam::DynamicList<T, SizeMin>::min_size() const
{
return SizeMin;
}
template<class T, int SizeMin>
inline Foam::label Foam::DynamicList<T, SizeMin>::capacity() const
inline Foam::label Foam::DynamicList<T, SizeMin>::capacity() const noexcept
{
return capacity_;
}
......
......@@ -541,7 +541,7 @@ void Foam::List<T>::operator=(std::initializer_list<T> list)
List_ACCESS(T, (*this), vp);
label i = 0;
for (const auto& val : list)
for (const T& val : list)
{
vp[i] = val;
++i;
......
......@@ -55,7 +55,6 @@ namespace Foam
{
// Forward declarations
class Istream;
class Ostream;
......@@ -112,6 +111,12 @@ class List
public:
// Related types
//- Declare type of subList
typedef SubList<T> subList;
// Static Member Functions
//- Return a null List
......@@ -199,12 +204,6 @@ public:
~List();
// Related types
//- Declare type of subList
typedef SubList<T> subList;
// Member Functions
// Edit
......
......@@ -122,7 +122,7 @@ public:
inline void operator=(const UList<T>& list);
//- Assignment of all entries to the given value
inline void operator=(const T& t);
inline void operator=(const T& val);
};
......
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