Closed dsharlet closed 4 years ago
I think this issue is now actually pretty good. Most/all rank mismatches are now reported as a single error at the call site, and the error is not hard to understand.
For example, using the wrong number of indices:
test/array_ref.cpp:39:5: error: no matching function for call to object of type 'dense_array_ref<int, 2>' (aka 'array_ref<int,
nda::shape<nda::dim<-9, -9, 1>, nda::dim<-9, -9, -9> > >')
ref_2d(x, y, 0) = 0;
^~~~~~
./array.h:1642:13: note: candidate template ignored: requirement 'sizeof...(Args) == rank()' was not satisfied [with Args = <int, int, int>]
reference operator() (Args... indices) const { return base_[shape_(indices...)]; }
^
./array.h:1649:8: note: candidate template ignored: requirement 'sizeof...(Args) == rank()' was not satisfied [with Args = <int, int, int>]
auto operator() (Args... ranges) const {
^
./array.h:1637:13: note: candidate function not viable: requires single argument 'indices', but 3 arguments were provided
reference operator() (const index_type& indices) const { return base_[shape_(indices)]; }
When using constructors or
operator()
incorrectly, the error messages are often huge and hard to decipher, for a few reasons:Issue (2) could be improved with more aggressive use of
static_assert
earlier in the API.Issue (1) is harder to address, but would be mitigated somewhat by addressing the second issue (because fewer symbols would be reported as part of errors).