external/coinmp/UnpackedTarball_coinmp.mk |    1 
 external/coinmp/bind2nd.patch.1           |   87 ++++++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)

New commits:
commit b97e8b9d13ef0f57f7cf0badbefcb038a8bbd137
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Wed Sep 14 14:36:40 2022 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Fri Sep 16 15:54:14 2022 +0200

    external/coinmp: Adapt to std::bind2nd gone from C++17
    
    ...which started to be an issue when building with recent Clang 16 trunk 
after
    
<https://github.com/llvm/llvm-project/commit/3e99b8d947ac024831e59be2b604ac67a24fed94>
    "C++/ObjC++: switch to gnu++17 as the default standard" against libc++.  
(Recent
    versions of GCC similarly default to C++17, but libstdc++ by default still
    provides bind2nd even for C++17.)  Alternatively, we could define
    _LIBCPP_ENABLE_CXX17_REMOVED_BINDERS to work around this.  But as these 
appear
    to be the only leftover occurrence of bind2nd across all of the code base, 
and
    all but one of them have already been addressed upstream, lets address it 
for
    good with this little patch.  (Where the last remaining occurrence not yet
    addressed upstream is fixed in the same way as the other upstream fixes, 
using a
    loop rather than e.g. a lambda that would force us to start to pass
    CXXFLAGS_CXX11 into ExternalProejct_coinmp.)
    
    Change-Id: Iddcdddd22ea4c6d537b64bf2cf0b887d11da162f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139931
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/external/coinmp/UnpackedTarball_coinmp.mk 
b/external/coinmp/UnpackedTarball_coinmp.mk
index 0764d428aace..b874f2b290f3 100644
--- a/external/coinmp/UnpackedTarball_coinmp.mk
+++ b/external/coinmp/UnpackedTarball_coinmp.mk
@@ -47,6 +47,7 @@ $(eval $(call gb_UnpackedTarball_add_patches,coinmp,\
        external/coinmp/register.patch \
        external/coinmp/configure-exit.patch \
        external/coinmp/pedantic-errors.patch \
+       external/coinmp/bind2nd.patch.1 \
 ))
 
 # vim: set noet sw=4 ts=4:
diff --git a/external/coinmp/bind2nd.patch.1 b/external/coinmp/bind2nd.patch.1
new file mode 100644
index 000000000000..5b3222eea9a0
--- /dev/null
+++ b/external/coinmp/bind2nd.patch.1
@@ -0,0 +1,87 @@
+--- a/Osi/src/OsiCommonTest/OsiSolverInterfaceTest.cpp
++++ b/Osi/src/OsiCommonTest/OsiSolverInterfaceTest.cpp
+@@ -1313,8 +1313,8 @@
+   int rows_to_delete_arr[] = { 0 } ;
+   si->deleteRows(1,rows_to_delete_arr) ;
+ 
+-  std::transform(objective,objective+4,objective,
+-               std::bind2nd(std::plus<double>(),0.15)) ;
++  for (int i = 0; i != 4; ++i)
++    objective[i] += 0.15;
+   si->setObjective(objective) ;
+   si->resolve() ;
+   OSIUNITTEST_ASSERT_ERROR(si->isProvenOptimal(),          return false, *si, 
"test16SebastianNowozin second resolve");
+
+The below is an excerpt from
+<https://github.com/coin-or/CoinUtils/commit/4f0dab267fc3976d0542f56e2939f900857147a6>
 "make c++17
+compatible":
+
+diff --git a/CoinUtils/src/CoinPackedMatrix.cpp 
b/CoinUtils/src/CoinPackedMatrix.cpp
+index c7631289..0b103159 100644
+--- a/CoinUtils/src/CoinPackedMatrix.cpp
++++ b/CoinUtils/src/CoinPackedMatrix.cpp
+@@ -1490,11 +1490,11 @@ CoinPackedMatrix::minorAppendSameOrdered(const 
CoinPackedMatrix& matrix)
+ 
+    // now insert the entries of matrix
+    for (i = majorDim_ - 1; i >= 0; --i) {
+-      const int l = matrix.length_[i];
+-      std::transform(matrix.index_ + matrix.start_[i],
+-              matrix.index_ + (matrix.start_[i] + l),
+-              index_ + (start_[i] + length_[i]),
+-              std::bind2nd(std::plus<int>(), minorDim_));
++      int l = matrix.length_[i];
++      CoinBigIndex put = start_[i]+length_[i];
++      const CoinBigIndex get = matrix.start_[i];
++      for (int j=0;j<l;j++)
++      index_[put+j]=matrix.index_[get+j]+minorDim_;
+       CoinMemcpyN(matrix.element_ + matrix.start_[i], l,
+                      element_ + (start_[i] + length_[i]));
+       length_[i] += l;
+diff --git a/CoinUtils/src/CoinPackedVector.cpp 
b/CoinUtils/src/CoinPackedVector.cpp
+index 7d90b3de..158a8373 100644
+--- a/CoinUtils/src/CoinPackedVector.cpp
++++ b/CoinUtils/src/CoinPackedVector.cpp
+@@ -284,8 +284,8 @@ CoinPackedVector::truncate( int n )
+ void
+ CoinPackedVector::operator+=(double value) 
+ {
+-   std::transform(elements_, elements_ + nElements_, elements_,
+-                std::bind2nd(std::plus<double>(), value) );
++  for (int i=0 ; i < nElements_; i++)
++    elements_[i] += value;
+ }
+ 
+ 
//-----------------------------------------------------------------------------
+@@ -293,8 +293,8 @@ CoinPackedVector::operator+=(double value)
+ void
+ CoinPackedVector::operator-=(double value) 
+ {
+-   std::transform(elements_, elements_ + nElements_, elements_,
+-                std::bind2nd(std::minus<double>(), value) );
++  for (int i=0 ; i < nElements_; i++)
++    elements_[i] -= value;
+ }
+ 
+ 
//-----------------------------------------------------------------------------
+@@ -302,8 +302,8 @@ CoinPackedVector::operator-=(double value)
+ void
+ CoinPackedVector::operator*=(double value) 
+ {
+-   std::transform(elements_, elements_ + nElements_, elements_,
+-                std::bind2nd(std::multiplies<double>(), value) );
++  for (int i=0 ; i < nElements_; i++)
++    elements_[i] *= value;
+ }
+ 
+ 
//-----------------------------------------------------------------------------
+@@ -311,8 +311,8 @@ CoinPackedVector::operator*=(double value)
+ void
+ CoinPackedVector::operator/=(double value) 
+ {
+-   std::transform(elements_, elements_ + nElements_, elements_,
+-                std::bind2nd(std::divides<double>(), value) );
++  for (int i=0 ; i < nElements_; i++)
++    elements_[i] /= value;
+ }
+ 
+ 
//#############################################################################

Reply via email to