dvalters / HAIL-CAESAR

The High-Performance Architecture-Independent LISFLOOD-CAESAR model of floodplain, river, and sediment dynamics
http://dvalters.github.io/HAIL-CAESAR
GNU General Public License v3.0
38 stars 12 forks source link

Fixed non-const reference to temporaries clang #8

Closed dvalters closed 6 years ago

dvalters commented 6 years ago

_(See also LSDTopoTools/LSDTTDevelopment#4)

Temporary objects cannot bind to non-const references. (https://stackoverflow.com/questions/8101489/c-no-matching-constructor-for-initialization-of-compiler-error), and you get this error when trying to compile with clang (v5.0):

/home/dav/Devel/HAIL-CAESAR/include/TNT/tnt_sparse_matrix_csr.h:97:3: error: no matching constructor for initialization of 'Array1D<int>' [clang-diagnostic-error]
                rowptr_(M, r), colind_(nz, c), dim1_(M), dim2_(N) {}
                ^          ~
                           *
include/TNT/tnt_array1d.h:63:11: note: candidate constructor not viable: no known conversion from 'const int *' to 'const int' for 2nd argument; dereference the argument with *
                 Array1D(int n, const T &a);
                 ^
include/TNT/tnt_array1d.h:64:11: note: candidate constructor not viable: 2nd argument ('const int *') would lose const qualifier
                 Array1D(int n,  T *a);

So adds an extra constructor with a const in this PR.