diff --git a/applications/test/SLList/Test-SLList.C b/applications/test/SLList/Test-SLList.C index 5fa9dc8433c984ee8636731da0c166669dbcd0a1..30baaa18e37855007e2081ff2be514816c2137a7 100644 --- a/applications/test/SLList/Test-SLList.C +++ b/applications/test/SLList/Test-SLList.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,7 +39,8 @@ using namespace Foam; int main(int argc, char *argv[]) { - SLList<scalar> myList; + SLList<scalar> myList{2.1, 3.4}; + myList = {2.1, 3.4, 4.3}; for (int i = 0; i<10; i++) { diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C index ddecdcb0bde22cd15a3b6d57bbf4ff2af97903d3..7854cc9d84cdd5c554e8e08c9bfd1eecd3661fe9 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,7 +23,6 @@ License \*---------------------------------------------------------------------------*/ -#include "error.H" #include "LList.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -33,9 +32,21 @@ Foam::LList<LListBase, T>::LList(const LList<LListBase, T>& lst) : LListBase() { - for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) + for (const T& val : lst) { - this->append(iter()); + this->append(val); + } +} + + +template<class LListBase, class T> +Foam::LList<LListBase, T>::LList(std::initializer_list<T> lst) +: + LListBase() +{ + for (const T& val : lst) + { + this->append(val); } } @@ -77,9 +88,21 @@ void Foam::LList<LListBase, T>::operator=(const LList<LListBase, T>& lst) { this->clear(); - for (const_iterator iter = lst.begin(); iter != lst.end(); ++iter) + for (const T& val : lst) { - this->append(iter()); + this->append(val); + } +} + + +template<class LListBase, class T> +void Foam::LList<LListBase, T>::operator=(std::initializer_list<T> lst) +{ + this->clear(); + + for (const T& val : lst) + { + this->append(val); } } @@ -88,5 +111,4 @@ void Foam::LList<LListBase, T>::operator=(const LList<LListBase, T>& lst) #include "LListIO.C" - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H index fd1c3e0aef5c807a01485a24bcb91239c0bef4da..cac481545ebe5cf58d9176fcf80e33b74f4b3d60 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LList.H @@ -37,7 +37,7 @@ SourceFiles #define LList_H #include "label.H" -#include "uLabel.H" +#include <initializer_list> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -121,6 +121,9 @@ public: //- Construct as copy LList(const LList<LListBase, T>&); + //- Construct from an initializer list + LList(std::initializer_list<T>); + //- Destructor ~LList(); @@ -206,8 +209,12 @@ public: // Member operators + //- Assignment operator void operator=(const LList<LListBase, T>&); + //- Assignment to an initializer list + void operator=(std::initializer_list<T>); + // STL type definitions diff --git a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C index c14ff358ea63d9dc45a6270b4b62b0896154696a..a766ee85b9975ac842a51cd886b3741058c9eb53 100644 --- a/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C +++ b/src/OpenFOAM/containers/LinkedLists/accessTypes/LList/LListIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -144,14 +144,9 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const LList<LListBase, T>& lst) os << nl << token::BEGIN_LIST << nl; // Write contents - for - ( - typename LList<LListBase, T>::const_iterator iter = lst.begin(); - iter != lst.end(); - ++iter - ) + for (const T& val : lst) { - os << iter() << nl; + os << val << nl; } // Write end of contents diff --git a/src/OpenFOAM/containers/LinkedLists/user/SLList.H b/src/OpenFOAM/containers/LinkedLists/user/SLList.H index 6cb3d6ac6251336c9c62d0ef8f2eda8429a85be6..8be3c5561eac1948969a677a50dc8f69c3e1fbd9 100644 --- a/src/OpenFOAM/containers/LinkedLists/user/SLList.H +++ b/src/OpenFOAM/containers/LinkedLists/user/SLList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Class +Alias Foam::SLList Description @@ -39,42 +39,9 @@ Description namespace Foam { - -/*---------------------------------------------------------------------------*\ - Class SLList Declaration -\*---------------------------------------------------------------------------*/ - -template<class T> -class SLList -: - public LList<SLListBase, T> -{ - -public: - - // Constructors - - //- Null construct - SLList() - {} - - //- Construct given initial T - explicit SLList(T a) - : - LList<SLListBase, T>(a) - {} - - //- Construct from Istream - explicit SLList(Istream& is) - : - LList<SLListBase, T>(is) - {} -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam + template<class T> + using SLList = LList<SLListBase, T>; +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 067894ad3d637da5e79abe554d0c6a8fdf0db996..f59582971eea20f3137bb00db2b9d77ef51f3604 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -61,8 +61,11 @@ template<class T, unsigned Size> Ostream& operator<<(Ostream&, const FixedList<T, Size>&); template<class T> class UList; -template<class T> class SLList; +class SLListBase; +template<class LListBase, class T> class LList; +template<class T> +using SLList = LList<SLListBase, T>; /*---------------------------------------------------------------------------*\ Class FixedList Declaration @@ -219,16 +222,16 @@ public: //- Return element of constant FixedList inline const T& operator[](const label) const; - //- Assignment from array operator. Takes linear time + //- Assignment to array operator. Takes linear time inline void operator=(const T v[Size]); - //- Assignment from UList operator. Takes linear time + //- Assignment to UList operator. Takes linear time inline void operator=(const UList<T>&); - //- Assignment from SLList operator. Takes linear time + //- Assignment to SLList operator. Takes linear time inline void operator=(const SLList<T>&); - //- Assignment from an initializer list. Takes linear time + //- Assignment to an initializer list. Takes linear time inline void operator=(std::initializer_list<T>); //- Assignment of all entries to the given value diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index d93e5fe86d72ca2f71a0a26fc2e16770c7ff48d1..448e4604ae8b1e108f57a9a51fcfc44f0ed5e2cc 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -62,7 +62,11 @@ template<class T> Istream& operator>>(Istream&, List<T>&); template<class T, unsigned Size> class FixedList; template<class T> class PtrList; -template<class T> class SLList; + +class SLListBase; +template<class LListBase, class T> class LList; +template<class T> +using SLList = LList<SLListBase, T>; template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv> class DynamicList; @@ -247,22 +251,22 @@ public: // Member operators - //- Assignment from UList operator. Takes linear time + //- Assignment to UList operator. Takes linear time void operator=(const UList<T>&); //- Assignment operator. Takes linear time void operator=(const List<T>&); - //- Assignment from SLList operator. Takes linear time + //- Assignment to SLList operator. Takes linear time void operator=(const SLList<T>&); - //- Assignment from UIndirectList operator. Takes linear time + //- Assignment to UIndirectList operator. Takes linear time void operator=(const UIndirectList<T>&); - //- Assignment from BiIndirectList operator. Takes linear time + //- Assignment to BiIndirectList operator. Takes linear time void operator=(const BiIndirectList<T>&); - //- Construct from an initializer list + //- Assignment to an initializer list void operator=(std::initializer_list<T>); //- Assignment of all entries to the given value diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C index ce704984e5e808fa751e7ea9623f4706a229d3ac..066528fe3d43080ccfc3b1f73c457df235125c9e 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C @@ -157,7 +157,7 @@ void Foam::ParticleCollector<CloudType>::initConcentricCircles() vector origin(this->coeffDict().lookup("origin")); - radius_ = this->coeffDict().lookup("radius"); + this->coeffDict().lookup("radius") >> radius_; nSector_ = readLabel(this->coeffDict().lookup("nSector")); label nS = nSector_;