diff --git a/src/OpenFOAM/containers/HashTables/Map/Map.H b/src/OpenFOAM/containers/HashTables/Map/Map.H index 46de9dbed..8ef2f560b 100644 --- a/src/OpenFOAM/containers/HashTables/Map/Map.H +++ b/src/OpenFOAM/containers/HashTables/Map/Map.H @@ -91,6 +91,11 @@ public: HashTable>(map) {} + //- Construct from an initializer list + Map(std::initializer_list> map) + : + HashTable>(map) + {} }; diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C index 784b1f9e1..fbafc9cf0 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C @@ -72,6 +72,15 @@ Foam::SortableList::SortableList(const SortableList& lst) {} +template +Foam::SortableList::SortableList(std::initializer_list values) +: + List(values) +{ + sort(); +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -138,20 +147,27 @@ inline void Foam::SortableList::operator=(const T& t) template -inline void Foam::SortableList::operator=(const UList& rhs) +inline void Foam::SortableList::operator=(const UList& lst) { - List::operator=(rhs); + List::operator=(lst); indices_.clear(); } template -inline void Foam::SortableList::operator=(const SortableList& rhs) +inline void Foam::SortableList::operator=(const SortableList& lst) { - List::operator=(rhs); - indices_ = rhs.indices(); + List::operator=(lst); + indices_ = lst.indices(); +} + + +template +inline void Foam::SortableList::operator=(std::initializer_list lst) +{ + List::operator=(lst); + sort(); } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H index a6f4b4586..65fb6dc7f 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H @@ -67,33 +67,36 @@ public: //- Null constructor, sort later (eg, after assignment or transfer) SortableList(); - //- Construct from UList, sorting immediately. + //- Construct from UList, sorting immediately explicit SortableList(const UList&); - //- Construct from transferred List, sorting immediately. + //- Construct from transferred List, sorting immediately explicit SortableList(const Xfer>&); - //- Construct given size. Sort later on. + //- Construct given size. Sort later on // The indices remain empty until the list is sorted explicit SortableList(const label size); - //- Construct given size and initial value. Sort later on. + //- Construct given size and initial value. Sort later on // The indices remain empty until the list is sorted SortableList(const label size, const T&); - //- Construct as copy. + //- Construct as copy SortableList(const SortableList&); + //- Construct from an initializer list, sorting immediately + SortableList(std::initializer_list); + // Member Functions - //- Return the list of sorted indices. Updated every sort. + //- Return the list of sorted indices. Updated every sort const labelList& indices() const { return indices_; } - //- Return non-const access to the sorted indices. Updated every sort. + //- Return non-const access to the sorted indices. Updated every sort labelList& indices() { return indices_; @@ -121,12 +124,14 @@ public: //- Assignment of all entries to the given value inline void operator=(const T&); - //- Assignment to UList operator. Takes linear time. + //- Assignment to UList operator. Takes linear time inline void operator=(const UList&); - //- Assignment operator. Takes linear time. + //- Assignment operator. Takes linear time inline void operator=(const SortableList&); + //- Assignment to an initializer list + void operator=(std::initializer_list); };