3

ビルダーとして acompressed_matrixを使用して aを作成しようとしています:coordinate_matrix

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

これは、boost 1.54 と clang を使用すると正常に動作するようですが、std=c++11 を使用してコンパイルすると、エラーがスローされます。

 choeger@daishi /tmp % clang++ test.cpp --std=c++11
In file included from test.cpp:1:
In file included from /usr/include/boost/numeric/ublas/io.hpp:18:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/sstream:38:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/istream:38:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/ios:40:
In file included from /usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/bits/char_traits.h:39:
/usr/bin/../lib/gcc/x86_64-redhat-linux/4.8.2/../../../../include/c++/4.8.2/bits/stl_algobase.h:147:7: error: no matching function for call to 'swap'
      swap(*__a, *__b);

C++ 11 とブースト 1.54 の既知の非互換性はありますか? それとも、C++11 エラーを起こしたのでしょうか? 1.55 の変更ログには、ublas もマトリックスも記載されていないため、まだ存在していると思います。

これは、gcc 4.8.2 と clang 3.4 の両方で発生します。

4

2 に答える 2

3

これは間違いなく Boost のバグです。問題は whenBOOST_UBLAS_STRICT_MATRIX_SPARSEが定義され、coordinate_matrixそのイテレータ型がプロキシ クラスをreference型として使用することです。

#ifndef BOOST_UBLAS_STRICT_MATRIX_SPARSE
        typedef T &reference;
#else
        typedef sparse_matrix_element<self_type> reference;
#endif

referenceこれは、前方反復子の型が真の参照であるという C++ 標準の要件に違反しています。C++11 [forward.iterators]/1 は次のように述べていXます。、...」。XreferenceTXconstreferenceconst T

このcoordinate_matrix事実にもかかわらず、イテレータは双方向イテレータであると主張しているため、未定義の動作が発生します。

于 2014-06-16T15:05:18.187 に答える