mrklein / openfoam-os-x

Patches for OpenFOAM(R) to build it on OS X
93 stars 33 forks source link

clarifications of some patched items #61

Closed olesenm closed 3 years ago

olesenm commented 3 years ago

Hi @mrklein - some small questions

 template<class T>
 void Foam::shuffle(UList<T>& a)
 {
-    std::random_shuffle(a.begin(), a.end());
+    std::random_device rd;
+    std::mt19937 g(rd());
+    std::shuffle(a.begin(), a.end(), g);
 }

Any particular issue or cost/benefit of this change?

mrklein commented 3 years ago

Hi,

random_shuffle is deprecated in C++14 and C++14 was necessary for new CGAL.

Code was taken from an example at cppreference (https://en.cppreference.com/w/cpp/algorithm/random_shuffle) without much thought.

olesenm commented 3 years ago

Ah, it would have paid for me to read the docs. Will update random_shuffle upstream accordingly. The c++14 change required for CGAL is known, but we are still playing the balancing act of keeping the requirements down (eg, centos7 only ships with gcc 4.8.5) while still moving forward. This also means that we ship with a slightly older CGAL for now. Patching the wmake rules to use c++14 (as you have done) makes the best sense for now to use newer system CGAL version. It's also what we do for the Ubuntu packages.

Thanks for the explanation!