View Issue Details

IDProjectCategoryView StatusLast Update
0002276OpenFOAMContributionpublic2016-09-30 18:51
ReporterMattijsJ Assigned Tohenry  
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformGNU/LinuxOSOpenSuSEOS Version13.2
Product Versiondev 
Fixed in Versiondev 
Summary0002276: more initializer_lists for containers
Descriptionmore initializer_lists for containers. This is a black box implementation by me.
TagsNo tags attached.

Activities

MattijsJ

2016-09-29 14:06

reporter  

initializer_list.patch (2,759 bytes)   
diff --git a/src/OpenFOAM/containers/HashTables/Map/Map.H b/src/OpenFOAM/containers/HashTables/Map/Map.H
index 46de9db..8ef2f56 100644
--- a/src/OpenFOAM/containers/HashTables/Map/Map.H
+++ b/src/OpenFOAM/containers/HashTables/Map/Map.H
@@ -91,6 +91,11 @@ public:
             HashTable<T, label, Hash<label>>(map)
         {}
 
+        //- Construct from an initializer list
+        Map(std::initializer_list<Tuple2<label, T>> map)
+        :
+            HashTable<T, label, Hash<label>>(map)
+        {}
 };
 
 
diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C
index 784b1f9..d6f733b 100644
--- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C
+++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C
@@ -72,6 +72,15 @@ Foam::SortableList<T>::SortableList(const SortableList<T>& lst)
 {}
 
 
+template<class T>
+Foam::SortableList<T>::SortableList(std::initializer_list<T> values)
+:
+    List<T>(values)
+{
+    sort();
+}
+
+
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 
diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H
index a6f4b45..05a20f7 100644
--- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H
+++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H
@@ -84,6 +84,9 @@ public:
         //- Construct as copy.
         SortableList(const SortableList<T>&);
 
+        //- Construct from an initializer list, sorting immediately.
+        explicit SortableList(std::initializer_list<T>);
+
 
     // Member Functions
 
diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C
index ea27071..7200dfb 100644
--- a/src/OpenFOAM/fields/Fields/Field/Field.C
+++ b/src/OpenFOAM/fields/Fields/Field/Field.C
@@ -244,6 +244,13 @@ Foam::Field<Type>::Field(const UList<Type>& list)
 {}
 
 
+template<class Type>
+Foam::Field<Type>::Field(const UIndirectList<Type>& list)
+:
+    List<Type>(list)
+{}
+
+
 #ifndef NoConstructFromTmp
 template<class Type>
 Foam::Field<Type>::Field(const tmp<Field<Type>>& tf)
diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H
index 87715a2..245870e 100644
--- a/src/OpenFOAM/fields/Fields/Field/Field.H
+++ b/src/OpenFOAM/fields/Fields/Field/Field.H
@@ -123,6 +123,9 @@ public:
         //- Construct as copy of a UList\<Type\>
         explicit Field(const UList<Type>&);
 
+        //- Construct as copy of a UIndirectList\<Type\>
+        explicit Field(const UIndirectList<Type>&);
+
         //- Construct by transferring the List contents
         explicit Field(const Xfer<List<Type>>&);
 
initializer_list.patch (2,759 bytes)   

henry

2016-09-30 18:51

manager   ~0006948

Resolved by commit 298003f3332124c43179e25770fb54f16d4af66d

Issue History

Date Modified Username Field Change
2016-09-29 14:06 MattijsJ New Issue
2016-09-29 14:06 MattijsJ File Added: initializer_list.patch
2016-09-30 18:51 henry Assigned To => henry
2016-09-30 18:51 henry Status new => resolved
2016-09-30 18:51 henry Resolution open => fixed
2016-09-30 18:51 henry Fixed in Version => dev
2016-09-30 18:51 henry Note Added: 0006948