diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index bc16f090aa..4fa4a0fbb4 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -115,7 +115,7 @@ public: // Constructors //- Construct null - inline DynamicList(); + inline constexpr DynamicList() noexcept; //- Construct an empty list with given reserve size. explicit inline DynamicList(const label nElem); diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index b383da6896..88b59d6fcd 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -56,7 +56,7 @@ inline void Foam::DynamicList::assignDynList // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -inline Foam::DynamicList::DynamicList() +inline constexpr Foam::DynamicList::DynamicList() noexcept : capacity_(0) {} diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C index e0cd4afae6..290789b67d 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.C +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.C @@ -37,11 +37,11 @@ Foam::label Foam::FixedList::find { if (start >= 0) { - List_CONST_ACCESS(T, *this, lst); + List_CONST_ACCESS(T, *this, list); for (label i = start; i < label(Size); ++i) { - if (lst[i] == val) + if (list[i] == val) { return i; } diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index a5ee5da624..b6f25a5021 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.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) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -40,14 +40,16 @@ SourceFiles #include "bool.H" #include "label.H" #include "uLabel.H" +#include "zero.H" #include "Hash.H" #include "autoPtr.H" #include "Swap.H" #include "SLListFwd.H" -#include #include #include +#include +#include // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -76,7 +78,7 @@ class FixedList { static_assert ( - Size && Size <= INT_MAX, + Size && Size <= std::numeric_limits::max(), "Size must be positive (non-zero) and also fit as a signed value" ); @@ -90,10 +92,13 @@ protected: // Protected Member Functions + //- True if there are two or more entries and all entries have + // identical values. + inline bool uniform() const; + //- Write the FixedList with its compound type void writeEntry(Ostream& os) const; - public: // STL type definitions @@ -139,7 +144,7 @@ public: { inline unsigned operator() ( - const FixedList& lst, + const FixedList& list, unsigned seed = 0 ) const; }; @@ -156,18 +161,21 @@ public: //- Null constructor inline FixedList() = default; - //- Construct from value + //- Construct and initialize all entries to given value explicit inline FixedList(const T& val); + //- Construct and initialize all entries to zero + explicit inline FixedList(const zero); + //- Copy construct from C-array - explicit inline FixedList(const T lst[Size]); + explicit inline FixedList(const T list[Size]); //- Copy constructor - inline FixedList(const FixedList& lst); + inline FixedList(const FixedList& list); //- Move construct by using move assignment for the individual //- list elements - inline FixedList(FixedList&& lst); + inline FixedList(FixedList&& list); //- Construct given begin/end iterators // Uses std::distance when verifying the size. @@ -175,13 +183,13 @@ public: inline FixedList(InputIterator begIter, InputIterator endIter); //- Construct from an initializer list - inline FixedList(std::initializer_list lst); + inline FixedList(std::initializer_list list); //- Construct from UList - explicit inline FixedList(const UList& lst); + explicit inline FixedList(const UList& list); //- Construct from SLList - explicit inline FixedList(const SLList& lst); + explicit inline FixedList(const SLList& list); //- Construct from Istream FixedList(Istream& is); @@ -250,7 +258,7 @@ public: inline void checkIndex(const label i) const; - // Search + // Search //- Find index of the first occurence of the value. // Linear search. @@ -261,7 +269,7 @@ public: inline bool found(const T& val, const label start=0) const; - // Edit + // Edit //- Dummy resize function // needed to make FixedList consistent with List @@ -285,7 +293,7 @@ public: //- Transfer by swapping using a move assignment for the content //- of the individual list elements - inline void transfer(FixedList& lst); + inline void transfer(FixedList& list); // Member operators @@ -297,25 +305,25 @@ public: inline const T& operator[](const label i) const; //- Assignment to array operator. Takes linear time - inline void operator=(const T lst[Size]); + inline void operator=(const T list[Size]); //- Assignment to UList operator. Takes linear time - inline void operator=(const UList& lst); + inline void operator=(const UList& list); //- Assignment to SLList operator. Takes linear time - inline void operator=(const SLList& lst); + inline void operator=(const SLList& list); //- Assignment to an initializer list. Takes linear time - inline void operator=(std::initializer_list lst); + inline void operator=(std::initializer_list list); //- Assignment of all entries to the given value inline void operator=(const T& val); //- Copy assignment - inline void operator=(const FixedList& lst); + inline void operator=(const FixedList& list); //- Move assignment - inline void operator=(FixedList&& lst); + inline void operator=(FixedList&& list); // Random access iterator (non-const) @@ -378,7 +386,7 @@ public: inline bool empty() const; //- Swap lists by swapping the content of the individual list elements - inline void swap(FixedList& lst); + inline void swap(FixedList& list); // STL member operators @@ -421,14 +429,14 @@ public: friend Istream& operator>> ( Istream& is, - FixedList& lst + FixedList& list ); //- Write to Ostream, as per writeList() with shortListLen=10 friend Ostream& operator<< ( Ostream& os, - const FixedList& lst + const FixedList& list ); }; diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index db4d46fffc..ea687cda98 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -30,6 +30,30 @@ License #include #include +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +inline bool Foam::FixedList::uniform() const +{ + if (Size > 1) + { + const T& val = first(); + + for (unsigned i=1; i @@ -43,31 +67,41 @@ inline Foam::FixedList::FixedList(const T& val) template -inline Foam::FixedList::FixedList(const T lst[Size]) +inline Foam::FixedList::FixedList(const zero) { for (unsigned i=0; i -inline Foam::FixedList::FixedList(const FixedList& lst) +inline Foam::FixedList::FixedList(const T list[Size]) { for (unsigned i=0; i -inline Foam::FixedList::FixedList(FixedList&& lst) +inline Foam::FixedList::FixedList(const FixedList& list) { for (unsigned i=0; i +inline Foam::FixedList::FixedList(FixedList&& list) +{ + for (unsigned i=0; i::FixedList template -inline Foam::FixedList::FixedList(std::initializer_list lst) +inline Foam::FixedList::FixedList(std::initializer_list list) { - checkSize(lst.size()); + checkSize(list.size()); - auto iter = lst.begin(); + auto iter = list.begin(); for (unsigned i=0; i::FixedList(std::initializer_list lst) template -inline Foam::FixedList::FixedList(const UList& lst) +inline Foam::FixedList::FixedList(const UList& list) { - checkSize(lst.size()); + checkSize(list.size()); for (unsigned i=0; i -inline Foam::FixedList::FixedList(const SLList& lst) +inline Foam::FixedList::FixedList(const SLList& list) { - checkSize(lst.size()); + checkSize(list.size()); - auto iter = lst.begin(); + auto iter = list.begin(); for (unsigned i=0; i::setSize(const label n) template -inline void Foam::FixedList::swap(FixedList& lst) +inline void Foam::FixedList::swap(FixedList& list) { for (unsigned i=0; i -inline void Foam::FixedList::transfer(FixedList& lst) +inline void Foam::FixedList::transfer(FixedList& list) { for (unsigned i=0; i::operator[](const label i) const template -inline void Foam::FixedList::operator=(const T lst[Size]) +inline void Foam::FixedList::operator=(const T list[Size]) { for (unsigned i=0; i -inline void Foam::FixedList::operator=(const UList& lst) +inline void Foam::FixedList::operator=(const UList& list) { - checkSize(lst.size()); + checkSize(list.size()); for (unsigned i=0; i -inline void Foam::FixedList::operator=(const SLList& lst) +inline void Foam::FixedList::operator=(const SLList& list) { - checkSize(lst.size()); + checkSize(list.size()); - typename SLList::const_iterator iter = lst.begin(); + auto iter = list.begin(); for (unsigned i=0; i::operator=(const SLList& lst) } template -inline void Foam::FixedList::operator=(std::initializer_list lst) +inline void Foam::FixedList::operator=(std::initializer_list list) { - checkSize(lst.size()); + checkSize(list.size()); - auto iter = lst.begin(); + auto iter = list.begin(); for (unsigned i=0; i::operator=(const T& val) } template -inline void Foam::FixedList::operator=(const FixedList& lst) +inline void Foam::FixedList::operator=(const FixedList& list) { for (unsigned i=0; i -inline void Foam::FixedList::operator=(FixedList&& lst) +inline void Foam::FixedList::operator=(FixedList&& list) { // No significant speedup observed for copy assignment on simple types, // use move assignment for generality with more complex types for (unsigned i=0; i template inline unsigned Foam::FixedList::Hash::operator() ( - const FixedList& lst, + const FixedList& list, unsigned seed ) const { if (contiguous()) { // Hash directly - return Hasher(lst.v_, sizeof(lst.v_), seed); + return Hasher(list.v_, sizeof(list.v_), seed); } // Hash incrementally @@ -555,7 +589,7 @@ inline unsigned Foam::FixedList::Hash::operator() for (unsigned i=0; i::writeList const label shortListLen ) const { - const FixedList& lst = *this; + const FixedList& list = *this; // Write list contents depending on data format if (os.format() == IOstream::ASCII || !contiguous()) { - // Can the contents be considered 'uniform' (ie, identical)? - bool uniform = (Size > 1 && contiguous()); - if (uniform) + if (contiguous() && list.uniform()) { - for (unsigned i=0; i::writeList for (unsigned i=0; i::writeList // Contents for (unsigned i=0; i::writeList // Binary, contiguous // write(...) includes surrounding start/end delimiters - os.write(reinterpret_cast(lst.cdata()), Size*sizeof(T)); + os.write(reinterpret_cast(list.cdata()), Size*sizeof(T)); } os.check(FUNCTION_NAME); @@ -154,7 +135,7 @@ Foam::FixedList::FixedList(Istream& is) template -Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& lst) +Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& list) { is.fatalCheck(FUNCTION_NAME); @@ -169,7 +150,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& lst) if (firstToken.isCompound()) { - lst = dynamicCast>> + list = dynamicCast>> ( firstToken.transferCompoundToken(is) ); @@ -179,7 +160,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& lst) const label len = firstToken.labelToken(); // List lengths must match - lst.checkSize(len); + list.checkSize(len); } else if (!firstToken.isPunctuation()) { @@ -202,7 +183,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& lst) { for (unsigned i=0; i> lst[i]; + is >> list[i]; is.fatalCheck ( @@ -224,7 +205,7 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& lst) for (unsigned i=0; i>(Foam::Istream& is, FixedList& lst) { // Binary and contiguous - is.read(reinterpret_cast(lst.data()), Size*sizeof(T)); + is.read(reinterpret_cast(list.data()), Size*sizeof(T)); is.fatalCheck ( @@ -249,9 +230,9 @@ Foam::Istream& Foam::operator>>(Foam::Istream& is, FixedList& lst) template -Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList& lst) +Foam::Ostream& Foam::operator<<(Ostream& os, const FixedList& list) { - return lst.writeList(os, 10); + return list.writeList(os, 10); } diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.C b/src/OpenFOAM/containers/Lists/PtrList/PtrList.C index a25776e029..d27a74223d 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.C +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.C @@ -29,38 +29,38 @@ License // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // template -Foam::PtrList::PtrList(const PtrList& lst) +Foam::PtrList::PtrList(const PtrList& list) : - UPtrList(lst.size()) + UPtrList(list.size()) { const label len = this->size(); for (label i=0; iptrs_[i] = (lst[i]).clone().ptr(); + this->ptrs_[i] = (list[i]).clone().ptr(); } } template template -Foam::PtrList::PtrList(const PtrList& lst, const CloneArg& cloneArg) +Foam::PtrList::PtrList(const PtrList& list, const CloneArg& cloneArg) : - UPtrList(lst.size()) + UPtrList(list.size()) { const label len = this->size(); for (label i=0; iptrs_[i] = (lst[i]).clone(cloneArg).ptr(); + this->ptrs_[i] = (list[i]).clone(cloneArg).ptr(); } } template -Foam::PtrList::PtrList(PtrList& lst, bool reuse) +Foam::PtrList::PtrList(PtrList& list, bool reuse) : - UPtrList(lst, reuse) + UPtrList(list, reuse) { if (!reuse) { @@ -68,21 +68,21 @@ Foam::PtrList::PtrList(PtrList& lst, bool reuse) for (label i=0; iptrs_[i] = (lst[i]).clone().ptr(); + this->ptrs_[i] = (list[i]).clone().ptr(); } } } template -Foam::PtrList::PtrList(const SLPtrList& lst) +Foam::PtrList::PtrList(const SLPtrList& list) : - UPtrList(lst.size()) + UPtrList(list.size()) { - if (lst.size()) + if (list.size()) { label i = 0; - for (auto iter = lst.cbegin(); iter != lst.cend(); ++iter) + for (auto iter = list.cbegin(); iter != list.cend(); ++iter) { this->ptrs_[i++] = (*iter).clone().ptr(); } @@ -128,7 +128,7 @@ void Foam::PtrList::clear() template -void Foam::PtrList::setSize(const label newLen) +void Foam::PtrList::resize(const label newLen) { if (newLen <= 0) { @@ -150,7 +150,7 @@ void Foam::PtrList::setSize(const label newLen) } // Any new elements are initialized to nullptr. - this->ptrs_.setSize(newLen, reinterpret_cast(0)); + this->ptrs_.resize(newLen, reinterpret_cast(0)); } } @@ -158,9 +158,9 @@ void Foam::PtrList::setSize(const label newLen) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -void Foam::PtrList::operator=(const PtrList& lst) +void Foam::PtrList::operator=(const PtrList& list) { - if (this == &lst) + if (this == &list) { FatalErrorInFunction << "attempted assignment to self for type " << typeid(T).name() @@ -168,17 +168,17 @@ void Foam::PtrList::operator=(const PtrList& lst) } const label oldLen = this->size(); - const label newLen = lst.size(); + const label newLen = list.size(); // Truncate (frees old pointers) or extend the length - setSize(newLen); + resize(newLen); if (newLen < oldLen) { // Copy values for existing entries for (label i=0; i::operator=(const PtrList& lst) // Copy values for existing entries for (label i=0; iptrs_[i] = (lst[i]).clone().ptr(); + this->ptrs_[i] = (list[i]).clone().ptr(); } } } diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H index 0a7e9d7e80..c04d92f7d6 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H @@ -83,26 +83,26 @@ public: // Constructors //- Construct null - PtrList() = default; + inline constexpr PtrList() noexcept; //- Construct with specified size, each element initialized to nullptr explicit inline PtrList(const label nElem); //- Copy construct using 'clone()' method on each element - PtrList(const PtrList& lst); + PtrList(const PtrList& list); //- Move construct - inline PtrList(PtrList&& lst); + inline PtrList(PtrList&& list); //- Copy construct with additional argument for 'clone()' template - PtrList(const PtrList& lst, const CloneArg& cloneArg); + PtrList(const PtrList& list, const CloneArg& cloneArg); //- Construct as copy or re-use as specified - PtrList(PtrList& lst, bool reuse); + PtrList(PtrList& list, bool reuse); //- Construct as copy of SLPtrList - explicit PtrList(const SLPtrList& lst); + explicit PtrList(const SLPtrList& list); //- Construct from Istream using given Istream constructor class template @@ -123,11 +123,11 @@ public: //- Reset size of PtrList. // New entries are initialized to nullptr, removed entries are deleted - void setSize(const label newLen); + void resize(const label newLen); //- Reset size of PtrList. // New entries are initialized to nullptr, removed entries are deleted - inline void resize(const label newLen); + inline void setSize(const label newLen); //- Append an element at the end of the list using UPtrList::append; @@ -139,7 +139,7 @@ public: inline void append(const tmp& tptr); //- Transfer into this list and annul the argument list - inline void transfer(PtrList& lst); + inline void transfer(PtrList& list); //- Return true if element is set (ie, not a nullptr) inline bool set(const label i) const; @@ -159,16 +159,16 @@ public: //- Copy assignment. // For existing list entries, values are copied from the list. // For new list entries, pointers are cloned from the list. - void operator=(const PtrList& lst); + void operator=(const PtrList& list); //- Move assignment - inline void operator=(PtrList&& lst); + inline void operator=(PtrList&& list); // IOstream operator //- Read PtrList from Istream, discarding contents of existing PtrList - friend Istream& operator>> (Istream& is, PtrList& lst); + friend Istream& operator>> (Istream& is, PtrList& list); }; diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H index 17019a1297..6b51538e96 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrListI.H @@ -28,6 +28,13 @@ License // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // +template +inline constexpr Foam::PtrList::PtrList() noexcept +: + UPtrList() +{} + + template inline Foam::PtrList::PtrList(const label nElem) : @@ -36,18 +43,18 @@ inline Foam::PtrList::PtrList(const label nElem) template -inline Foam::PtrList::PtrList(PtrList&& lst) +inline Foam::PtrList::PtrList(PtrList&& list) : - UPtrList(std::move(lst)) + UPtrList(std::move(list)) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -inline void Foam::PtrList::resize(const label newLen) +inline void Foam::PtrList::setSize(const label newLen) { - this->setSize(newLen); + this->resize(newLen); } @@ -68,16 +75,14 @@ inline void Foam::PtrList::append(const tmp& tptr) template inline bool Foam::PtrList::set(const label i) const { - return this->ptrs_[i] != nullptr; + return UPtrList::set(i); } template inline Foam::autoPtr Foam::PtrList::set(const label i, T* ptr) { - autoPtr old(this->ptrs_[i]); - this->ptrs_[i] = ptr; - return old; + return autoPtr(UPtrList::set(i, ptr)); } @@ -104,20 +109,19 @@ inline Foam::autoPtr Foam::PtrList::set template -inline void Foam::PtrList::transfer(PtrList& lst) +inline void Foam::PtrList::transfer(PtrList& list) { this->clear(); - UPtrList::swap(lst); + UPtrList::transfer(list); } // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -inline void Foam::PtrList::operator=(PtrList&& lst) +inline void Foam::PtrList::operator=(PtrList&& list) { - this->clear(); - this->swap(lst); + this->transfer(list); } diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C index 139d5897bc..e3c7096497 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C @@ -28,7 +28,10 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -inline Foam::SortableList::SortableList() +inline constexpr Foam::SortableList::SortableList() noexcept +: + List(), + indices_() {} diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H index 99b1912170..c86656ffff 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H @@ -65,7 +65,7 @@ public: // Constructors //- Null constructor, sort later (eg, after assignment or transfer) - inline SortableList(); + inline constexpr SortableList() noexcept; //- Construct given size, sort later. // The indices remain empty until the list is sorted diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H index e8e0f30c38..189c9cd6c5 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H @@ -68,6 +68,15 @@ class UIndirectList UList& values_; const labelUList& addressing_; +protected: + + // Protected Member Functions + + //- True if there are two or more entries and all entries have + // identical values. + inline bool uniform() const; + + public: // STL type definitions diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H index 47d88a7db2..78ed22683b 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListI.H @@ -23,6 +23,32 @@ License \*---------------------------------------------------------------------------*/ +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +inline bool Foam::UIndirectList::uniform() const +{ + const label len = this->size(); + + if (len > 1) + { + const T& val = (*this)[0]; + + for (label i=1; i diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C index 9f3b8bbfa6..863288c302 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectListIO.C @@ -37,37 +37,17 @@ Foam::Ostream& Foam::UIndirectList::writeList const label shortListLen ) const { - const UIndirectList& L = *this; + const UIndirectList& list = *this; - const label len = L.size(); + const label len = list.size(); // Write list contents depending on data format if (os.format() == IOstream::ASCII || !contiguous()) { - // Can the contents be considered 'uniform' (ie, identical)? - bool uniform = (len > 1 && contiguous()); - if (uniform) + if (contiguous() && list.uniform()) { - for (label i=1; i < len; ++i) - { - if (L[i] != L[0]) - { - uniform = false; - break; - } - } - } - - if (uniform) - { - // Size and start delimiter - os << len << token::BEGIN_BLOCK; - - // Contents - os << L[0]; - - // End delimiter - os << token::END_BLOCK; + // Two or more entries, and all entries have identical values. + os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK; } else if ( @@ -82,7 +62,7 @@ Foam::Ostream& Foam::UIndirectList::writeList for (label i=0; i < len; ++i) { if (i) os << token::SPACE; - os << L[i]; + os << list[i]; } // End delimiter @@ -96,7 +76,7 @@ Foam::Ostream& Foam::UIndirectList::writeList // Contents for (label i=0; i < len; ++i) { - os << L[i] << nl; + os << list[i] << nl; } // End delimiter @@ -119,7 +99,7 @@ Foam::Ostream& Foam::UIndirectList::writeList { os.writeRaw ( - reinterpret_cast(&(L[i])), + reinterpret_cast(&(list[i])), sizeof(T) ); } diff --git a/src/OpenFOAM/containers/Lists/UList/UList.H b/src/OpenFOAM/containers/Lists/UList/UList.H index 2d31afac2c..7d144c7979 100644 --- a/src/OpenFOAM/containers/Lists/UList/UList.H +++ b/src/OpenFOAM/containers/Lists/UList/UList.H @@ -108,6 +108,10 @@ protected: // Use with care inline void size(const label n); + //- True if there are two or more entries and all entries have + // identical values. + inline bool uniform() const; + //- Write the UList with its compound type void writeEntry(Ostream& os) const; @@ -433,7 +437,7 @@ public: inline bool empty() const; //- Swap content with another UList of the same type in constant time - inline void swap(UList& lst); + inline void swap(UList& list); // STL member operators @@ -476,7 +480,7 @@ public: friend Ostream& operator<< ( Ostream& os, - const UList& lst + const UList& list ); //- Read List contents from Istream. @@ -508,11 +512,11 @@ void shuffle(UList& a); // Reverse the first n elements of the list template -inline void reverse(UList& lst, const label n); +inline void reverse(UList& list, const label n); // Reverse all the elements of the list template -inline void reverse(UList& lst); +inline void reverse(UList& list); // Exchange contents of lists - see UList::swap(). template diff --git a/src/OpenFOAM/containers/Lists/UList/UListI.H b/src/OpenFOAM/containers/Lists/UList/UListI.H index bd41d2ae55..f17852673a 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListI.H +++ b/src/OpenFOAM/containers/Lists/UList/UListI.H @@ -27,6 +27,33 @@ License #include "pTraits.H" #include "Swap.H" +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +template +inline bool Foam::UList::uniform() const +{ + const label len = size(); + + if (len > 1) + { + const T& val = first(); + + for (label i=1; i @@ -358,29 +385,29 @@ inline bool Foam::UList::empty() const template -inline void Foam::UList::swap(UList& lst) +inline void Foam::UList::swap(UList& list) { - Foam::Swap(size_, lst.size_); - Foam::Swap(v_, lst.v_); + Foam::Swap(size_, list.size_); + Foam::Swap(v_, list.v_); } // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // template -inline void Foam::reverse(UList& lst, const label n) +inline void Foam::reverse(UList& list, const label n) { for (label i=0; i -inline void Foam::reverse(UList& lst) +inline void Foam::reverse(UList& list) { - reverse(lst, lst.size()); + reverse(list, list.size()); } diff --git a/src/OpenFOAM/containers/Lists/UList/UListIO.C b/src/OpenFOAM/containers/Lists/UList/UListIO.C index 96bbc6b970..7b5805964b 100644 --- a/src/OpenFOAM/containers/Lists/UList/UListIO.C +++ b/src/OpenFOAM/containers/Lists/UList/UListIO.C @@ -74,37 +74,17 @@ Foam::Ostream& Foam::UList::writeList const label shortListLen ) const { - const UList& L = *this; + const UList& list = *this; - const label len = L.size(); + const label len = list.size(); // Write list contents depending on data format if (os.format() == IOstream::ASCII || !contiguous()) { - // Can the contents be considered 'uniform' (ie, identical)? - bool uniform = (len > 1 && contiguous()); - if (uniform) + if (contiguous() && list.uniform()) { - for (label i=1; i < len; ++i) - { - if (L[i] != L[0]) - { - uniform = false; - break; - } - } - } - - if (uniform) - { - // Size and start delimiter - os << len << token::BEGIN_BLOCK; - - // Contents - os << L[0]; - - // End delimiter - os << token::END_BLOCK; + // Two or more entries, and all entries have identical values. + os << len << token::BEGIN_BLOCK << list[0] << token::END_BLOCK; } else if ( @@ -119,7 +99,7 @@ Foam::Ostream& Foam::UList::writeList for (label i=0; i < len; ++i) { if (i) os << token::SPACE; - os << L[i]; + os << list[i]; } // End delimiter @@ -133,7 +113,7 @@ Foam::Ostream& Foam::UList::writeList // Contents for (label i=0; i < len; ++i) { - os << L[i] << nl; + os << list[i] << nl; } // End delimiter @@ -150,8 +130,8 @@ Foam::Ostream& Foam::UList::writeList // write(...) includes surrounding start/end delimiters os.write ( - reinterpret_cast(L.cdata()), - L.byteSize() + reinterpret_cast(list.cdata()), + list.byteSize() ); } } @@ -164,17 +144,17 @@ Foam::Ostream& Foam::UList::writeList // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // template -Foam::Ostream& Foam::operator<<(Ostream& os, const UList& lst) +Foam::Ostream& Foam::operator<<(Ostream& os, const UList& list) { - return lst.writeList(os, 10); + return list.writeList(os, 10); } template -Foam::Istream& Foam::operator>>(Istream& is, UList& lst) +Foam::Istream& Foam::operator>>(Istream& is, UList& list) { // The target list length - must match with sizes read - const label len = lst.size(); + const label len = list.size(); is.fatalCheck(FUNCTION_NAME); @@ -207,7 +187,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList& lst) for (label i = 0; i < len; ++i) { - lst[i] = std::move(elems[i]); + list[i] = std::move(elems[i]); } return is; @@ -241,7 +221,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList& lst) { for (label i=0; i> lst[i]; + is >> list[i]; is.fatalCheck ( @@ -264,7 +244,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList& lst) for (label i=0; i>(Istream& is, UList& lst) { // Non-empty, binary, contiguous - is.read(reinterpret_cast(lst.data()), len*sizeof(T)); + is.read(reinterpret_cast(list.data()), len*sizeof(T)); is.fatalCheck ( @@ -315,7 +295,7 @@ Foam::Istream& Foam::operator>>(Istream& is, UList& lst) // Move assign each list element for (label i = 0; i < len; ++i) { - lst[i] = std::move(sll.removeHead()); + list[i] = std::move(sll.removeHead()); } return is; diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H index bd4f64ebdf..ae2061d4fb 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrList.H @@ -56,7 +56,7 @@ namespace Foam template class PtrList; template class UPtrList; -template Ostream& operator<<(Ostream& os, const UPtrList& lst); +template Ostream& operator<<(Ostream& os, const UPtrList& list); /*---------------------------------------------------------------------------*\ @@ -96,7 +96,7 @@ public: // Constructors //- Construct null - UPtrList() = default; + inline constexpr UPtrList() noexcept; //- Construct with specified size, each element initialized to nullptr explicit inline UPtrList(const label len); @@ -104,19 +104,19 @@ public: //- Construct from PtrList, copying addresses of each list element. // The argument is non-const access since this UPtrList can be used // to change its values. - explicit inline UPtrList(PtrList& lst); + explicit inline UPtrList(PtrList& list); //- Construct from UList, taking addresses of each list element - explicit UPtrList(UList& lst); + explicit UPtrList(UList& list); //- Construct as copy or re-use as specified - inline UPtrList(UPtrList& lst, bool reuse); + inline UPtrList(UPtrList& list, bool reuse); //- Copy construct - inline UPtrList(const UPtrList& lst) = default; + inline UPtrList(const UPtrList& list) = default; //- Move construct - inline UPtrList(UPtrList&& lst); + inline UPtrList(UPtrList&& list); // Member functions @@ -149,20 +149,20 @@ public: //- Reset size of UPtrList. // New entries are initialized to nullptr. - inline void setSize(const label newLen); + inline void resize(const label newLen); //- Reset size of UPtrList. // New entries are initialized to nullptr. - inline void resize(const label newLen); + inline void setSize(const label newLen); //- Append an element to the end of the list inline void append(T* ptr); //- Swap content - inline void swap(UPtrList& lst); + inline void swap(UPtrList& list); //- Transfer contents into this list and annul the argument - inline void transfer(UPtrList& lst); + inline void transfer(UPtrList& list); //- Return true if element is set (ie, not a nullptr) inline bool set(const label i) const; @@ -187,10 +187,10 @@ public: inline const T* operator()(const label i) const; //- Copy assignment - UPtrList& operator=(const UPtrList& lst) = default; + UPtrList& operator=(const UPtrList& list) = default; //- Move assignment - inline void operator=(UPtrList&& lst); + inline void operator=(UPtrList&& list); // Iterators @@ -319,7 +319,7 @@ public: // IOstream operator //- Write UPtrList to Ostream - friend Ostream& operator<< (Ostream& os, const UPtrList& lst); + friend Ostream& operator<< (Ostream& os, const UPtrList& list); }; diff --git a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H index 34cd46d015..be76d3ea34 100644 --- a/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H +++ b/src/OpenFOAM/containers/Lists/UPtrList/UPtrListI.H @@ -25,6 +25,13 @@ License // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // +template +inline constexpr Foam::UPtrList::UPtrList() noexcept +: + ptrs_() +{} + + template inline Foam::UPtrList::UPtrList(const label len) : @@ -33,23 +40,23 @@ inline Foam::UPtrList::UPtrList(const label len) template -inline Foam::UPtrList::UPtrList(PtrList& lst) +inline Foam::UPtrList::UPtrList(PtrList& list) : - ptrs_(lst.ptrs_) + ptrs_(list.ptrs_) {} template -inline Foam::UPtrList::UPtrList(UPtrList&& lst) +inline Foam::UPtrList::UPtrList(UPtrList&& list) : - ptrs_(std::move(lst.ptrs_)) + ptrs_(std::move(list.ptrs_)) {} template -inline Foam::UPtrList::UPtrList(UPtrList& lst, bool reuse) +inline Foam::UPtrList::UPtrList(UPtrList& list, bool reuse) : - ptrs_(lst.ptrs_, reuse) + ptrs_(list.ptrs_, reuse) {} @@ -77,16 +84,16 @@ inline void Foam::UPtrList::clear() template -inline void Foam::UPtrList::swap(UPtrList& lst) +inline void Foam::UPtrList::swap(UPtrList& list) { - ptrs_.swap(lst.ptrs_); + ptrs_.swap(list.ptrs_); } template -inline void Foam::UPtrList::transfer(UPtrList& lst) +inline void Foam::UPtrList::transfer(UPtrList& list) { - ptrs_.transfer(lst.ptrs_); + ptrs_.transfer(list.ptrs_); } @@ -119,7 +126,7 @@ inline const T& Foam::UPtrList::last() const template -inline void Foam::UPtrList::setSize(const label newLen) +inline void Foam::UPtrList::resize(const label newLen) { if (newLen <= 0) { @@ -131,15 +138,15 @@ inline void Foam::UPtrList::setSize(const label newLen) if (newLen != oldLen) { // Truncate or extend. Any new elements are initialized to nullptr. - ptrs_.setSize(newLen, reinterpret_cast(0)); + ptrs_.resize(newLen, reinterpret_cast(0)); } } template -inline void Foam::UPtrList::resize(const label nElem) +inline void Foam::UPtrList::setSize(const label newLen) { - this->setSize(nElem); + this->resize(newLen); } @@ -147,7 +154,7 @@ template inline void Foam::UPtrList::append(T* ptr) { const label idx = this->size(); - ptrs_.setSize(idx + 1); + ptrs_.resize(idx + 1); ptrs_[idx] = ptr; } @@ -590,10 +597,9 @@ Foam::UPtrList::end() const // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template -inline void Foam::UPtrList::operator=(UPtrList&& lst) +inline void Foam::UPtrList::operator=(UPtrList&& list) { - this->clear(); - this->swap(lst); + this->transfer(list); } diff --git a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.C b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.C index 17a9ce9170..d9778371b4 100644 --- a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.C +++ b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.C @@ -105,7 +105,7 @@ void checkFields // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template class Field, class Type> -FieldField::FieldField() +constexpr FieldField::FieldField() noexcept : PtrList>() {} diff --git a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H index 2f2b273535..19d4ff5cdc 100644 --- a/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H +++ b/src/OpenFOAM/fields/FieldFields/FieldField/FieldField.H @@ -46,7 +46,7 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators +// Forward declarations template class Field, class Type> class FieldField; @@ -87,7 +87,7 @@ public: //- Construct null // Used for temporary fields which are initialised after construction - FieldField(); + constexpr FieldField() noexcept; //- Construct given size // Used for temporary fields which are initialised after construction diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H index 3531b44d9e..80e7455006 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicField.H @@ -100,7 +100,7 @@ public: // Constructors //- Construct null - inline DynamicField(); + inline constexpr DynamicField() noexcept; //- Construct with given capacity. explicit inline DynamicField(const label len); diff --git a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H index 316b43c9c2..1f7b5c479f 100644 --- a/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H +++ b/src/OpenFOAM/fields/Fields/DynamicField/DynamicFieldI.H @@ -54,10 +54,10 @@ inline void Foam::DynamicField::assignDynField // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -inline Foam::DynamicField::DynamicField() +inline constexpr Foam::DynamicField::DynamicField() noexcept : Field(), - capacity_(Field::size()) + capacity_(0) {} diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index 8432190fb5..a85ad3986a 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -37,83 +37,6 @@ const char* const Foam::Field::typeName("Field"); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -Foam::Field::Field() -: - List() -{} - - -template -Foam::Field::Field(const label len) -: - List(len) -{} - - -template -Foam::Field::Field(const label len, const Type& val) -: - List(len, val) -{} - - -template -Foam::Field::Field(const label len, const zero) -: - List(len, Zero) -{} - - -template -Foam::Field::Field(const Field& fld) -: - List(fld) -{} - - -template -Foam::Field::Field(const UList& list) -: - List(list) -{} - - -template -Foam::Field::Field(const UIndirectList& list) -: - List(list) -{} - - -template -Foam::Field::Field(Field&& fld) -: - List() -{ - List::transfer(fld); -} - - -template -Foam::Field::Field(List&& list) -: - List() -{ - List::transfer(list); -} - - -template -template -Foam::Field::Field(DynamicList&& list) -: - List() -{ - List::transfer(list); -} - - template Foam::Field::Field ( @@ -256,31 +179,6 @@ Foam::Field::Field } -template -Foam::Field::Field(Field& fld, bool reuse) -: - List(fld, reuse) -{} - - -#ifndef NoConstructFromTmp -template -Foam::Field::Field(const tmp>& tfld) -: - List(tfld.constCast(), tfld.movable()) -{ - tfld.clear(); -} -#endif - - -template -Foam::Field::Field(Istream& is) -: - List(is) -{} - - template Foam::Field::Field ( @@ -356,13 +254,6 @@ Foam::Field::Field } -template -Foam::tmp> Foam::Field::clone() const -{ - return tmp>::New(*this); -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template @@ -739,13 +630,17 @@ void Foam::Field::writeEntry(const word& keyword, Ostream& os) const { os.writeKeyword(keyword); + const label len = this->size(); + // Can the contents be considered 'uniform' (ie, identical)? - bool uniform = (this->size() && contiguous()); + bool uniform = (contiguous() && len); if (uniform) { - forAll(*this, i) + const Type& val = this->operator[](0); + + for (label i=1; ioperator[](i) != this->operator[](0)) + if (val != this->operator[](i)) { uniform = false; break; @@ -783,20 +678,6 @@ void Foam::Field::operator=(const Field& rhs) } -template -void Foam::Field::operator=(const UList& rhs) -{ - List::operator=(rhs); -} - - -template -void Foam::Field::operator=(const SubField& rhs) -{ - List::operator=(rhs); -} - - template void Foam::Field::operator=(const tmp& rhs) { @@ -811,42 +692,6 @@ void Foam::Field::operator=(const tmp& rhs) } -template -void Foam::Field::operator=(Field&& rhs) -{ - List::transfer(rhs); -} - - -template -void Foam::Field::operator=(List&& rhs) -{ - List::transfer(rhs); -} - - -template -template -void Foam::Field::operator=(DynamicList&& rhs) -{ - List::transfer(rhs); -} - - -template -void Foam::Field::operator=(const Type& val) -{ - List::operator=(val); -} - - -template -void Foam::Field::operator=(const zero) -{ - List::operator=(Zero); -} - - template template void Foam::Field::operator=(const VectorSpace& vs) diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H index deb6e58b50..e8a91b0306 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.H +++ b/src/OpenFOAM/fields/Fields/Field/Field.H @@ -31,6 +31,7 @@ SourceFiles FieldFunctions.H FieldFunctionsM.H FieldMapper.H + FieldI.H FieldM.H Field.C FieldFunctions.C @@ -103,36 +104,36 @@ public: //- Construct null // For temporary fields that are initialised after construction - Field(); + inline constexpr Field() noexcept; //- Construct given size // For temporary fields that are initialised after construction - explicit Field(const label len); + inline explicit Field(const label len); //- Construct given size and initial value - Field(const label len, const Type& val); + inline Field(const label len, const Type& val); //- Construct given size and initial values of zero - Field(const label len, const zero); + inline Field(const label len, const zero); //- Copy construct - Field(const Field& fld); + inline Field(const Field& fld); //- Copy construct from UList\ - explicit Field(const UList& list); + inline explicit Field(const UList& list); //- Copy construct from UIndirectList\ - explicit Field(const UIndirectList& list); + inline explicit Field(const UIndirectList& list); //- Move construct from Field - Field(Field&& fld); + inline Field(Field&& fld); //- Move construct from List - Field(List&& list); + inline Field(List&& list); //- Move construct from DynamicList template - Field(DynamicList&& list); + inline Field(DynamicList&& list); //- Construct by 1 to 1 mapping from the given field Field @@ -219,21 +220,21 @@ public: ); //- Copy construct or re-use as specified. - Field(Field& fld, bool reuse); + inline Field(Field& fld, bool reuse); //- Copy or move construct from tmp #ifndef NoConstructFromTmp - Field(const tmp>& tfld); + inline Field(const tmp>& tfld); #endif //- Construct from Istream - Field(Istream& is); + inline Field(Istream& is); //- Construct from a dictionary entry Field(const word& keyword, const dictionary& dict, const label len); //- Clone - tmp> clone() const; + inline tmp> clone() const; //- Return a pointer to a new calculatedFvPatchFieldField created on // freestore without setting patchField values @@ -358,21 +359,21 @@ public: //- Copy assignment void operator=(const Field&); - void operator=(const UList&); - void operator=(const SubField&); void operator=(const tmp>&); + inline void operator=(const UList&); + inline void operator=(const SubField&); //- Move assignment - void operator=(Field&& rhs); - void operator=(List&& rhs); + inline void operator=(Field&& rhs); + inline void operator=(List&& rhs); template - void operator=(DynamicList&& rhs); + inline void operator=(DynamicList&& rhs); //- Value assignment - void operator=(const Type&); - void operator=(const zero); + inline void operator=(const Type& val); + inline void operator=(const zero); template void operator=(const VectorSpace&); @@ -412,6 +413,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "FieldI.H" #include "FieldFunctions.H" #ifdef NoRepository diff --git a/src/OpenFOAM/fields/Fields/Field/FieldI.H b/src/OpenFOAM/fields/Fields/Field/FieldI.H new file mode 100644 index 0000000000..10101a2b2f --- /dev/null +++ b/src/OpenFOAM/fields/Fields/Field/FieldI.H @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +inline constexpr Foam::Field::Field() noexcept +: + List() +{} + + +template +inline Foam::Field::Field(const label len) +: + List(len) +{} + + +template +inline Foam::Field::Field(const label len, const Type& val) +: + List(len, val) +{} + + +template +inline Foam::Field::Field(const label len, const zero) +: + List(len, Zero) +{} + + +template +inline Foam::Field::Field(const Field& fld) +: + List(fld) +{} + + +template +inline Foam::Field::Field(const UList& list) +: + List(list) +{} + + +template +inline Foam::Field::Field(const UIndirectList& list) +: + List(list) +{} + + +template +inline Foam::Field::Field(Field&& fld) +: + List() +{ + List::transfer(fld); +} + + +template +inline Foam::Field::Field(List&& list) +: + List() +{ + List::transfer(list); +} + + +template +template +inline Foam::Field::Field(DynamicList&& list) +: + List() +{ + List::transfer(list); +} + + +template +inline Foam::Field::Field(Field& fld, bool reuse) +: + List(fld, reuse) +{} + + +#ifndef NoConstructFromTmp +template +inline Foam::Field::Field(const tmp>& tfld) +: + List(tfld.constCast(), tfld.movable()) +{ + tfld.clear(); +} +#endif + + +template +inline Foam::Field::Field(Istream& is) +: + List(is) +{} + + +template +inline Foam::tmp> Foam::Field::clone() const +{ + return tmp>::New(*this); +} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +template +inline void Foam::Field::operator=(const UList& rhs) +{ + List::operator=(rhs); +} + + +template +inline void Foam::Field::operator=(const SubField& rhs) +{ + List::operator=(rhs); +} + + +template +inline void Foam::Field::operator=(Field&& rhs) +{ + List::transfer(rhs); +} + + +template +inline void Foam::Field::operator=(List&& rhs) +{ + List::transfer(rhs); +} + + +template +template +inline void Foam::Field::operator=(DynamicList&& rhs) +{ + List::transfer(rhs); +} + + +template +inline void Foam::Field::operator=(const Type& val) +{ + List::operator=(val); +} + + +template +inline void Foam::Field::operator=(const zero) +{ + List::operator=(Zero); +} + + + +// ************************************************************************* // diff --git a/src/OpenFOAM/memory/refCount/refCount.H b/src/OpenFOAM/memory/refCount/refCount.H index 5b6e22c681..ba4a362a92 100644 --- a/src/OpenFOAM/memory/refCount/refCount.H +++ b/src/OpenFOAM/memory/refCount/refCount.H @@ -60,7 +60,7 @@ public: // Constructors //- Construct null initializing count to 0 - refCount() + constexpr refCount() noexcept : count_(0) {} @@ -69,13 +69,13 @@ public: // Member Functions //- Return the current reference count - int count() const + int count() const noexcept { return count_; } //- Return true if the reference count is zero - bool unique() const + bool unique() const noexcept { return !count_; }