Subject: [Boost-bugs] [Boost C++ Libraries] #10127: coordinate_matrix sort() fails on to std::swap
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-06-16 08:56:57
#10127: coordinate_matrix sort() fails on to std::swap
-----------------------+------------------------------
Reporter: anonymous | Type: Bugs
Status: new | Milestone: To Be Determined
Component: None | Version: Boost 1.54.0
Severity: Problem | Keywords:
-----------------------+------------------------------
Orginally posted here:
http://stackoverflow.com/questions/24228772/c11-compatibility-of-sparse-
matrix-implementations
The following program does not compile with gcc 4.8 or clang 3.4 when
--std=c++11 is set:
{{{
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
using namespace boost::numeric::ublas;
int main(int argc, char** argv) {
coordinate_matrix<int> m1(100, 100, 100);
for (int i = 0; i < 100; i++)
m1.insert_element(i,i,i);
compressed_matrix<int> m2(m1, 100);
}
}}}
We can solve the issue by providing a swap() routine:
{{{
#include <boost/numeric/ublas/io.hpp>
#include <boost/numeric/ublas/matrix_sparse.hpp>
using namespace boost::numeric::ublas;
namespace std {
template<class M>
inline
void swap (boost::numeric::ublas::index_triple<M> i1,
boost::numeric::ublas::index_triple<M> i2) {
i1.swap (i2);
}
}
int main(int argc, char** argv) {
coordinate_matrix<int> m1(100, 100, 100);
for (int i = 0; i < 100; i++)
m1.insert_element(i,i,i);
compressed_matrix<int> m2(m1, 100);
}
}}}
I am not an expert C++ template programmer, so I am unable to decide what
is the cause here, but the C++ reference on std::sort explicitly mentions
a swap() method.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/10127> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:16 UTC