office-gobmx/external/coinmp/bind2nd.patch.1
Stephan Bergmann b97e8b9d13 external/coinmp: Adapt to std::bind2nd gone from C++17
...which started to be an issue when building with recent Clang 16 trunk after
<3e99b8d947>
"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 <sbergman@redhat.com>
2022-09-16 15:54:14 +02:00

87 lines
3.3 KiB
Groff

--- 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;
}
//#############################################################################