Open yrjo-easics opened 1 year ago
Could it be that xt::range
is not yet assigned, and that your const
ness explicitly conflicts with this?
What exactly do you mean by not yet assigned? Are ranges also lazy, like tensor expressions?
My first guess was that it had something to do with the range type being forwarded as const.
Indeed, that it is lazy. This is not a part of the code that is my expertise, however, I would find it surprising that a lazy expression could be const
.
Upon further inspection I think I've found the cause of my problem:
The get_slice_type typedef in xslice.hpp seems to select the wrong specialization when SL is const xrange_adapter<...>
instead of xrange_adapter<...>
.
This small change solved the compilation issue for me: https://github.com/yrjok/xtensor/commit/48d4c2294544b5b852e2b653bf7e3bc8bb260237
Not sure if this fits in the grand scheme of things because I am not familiar with the xtensor codebase.
The following code to create a view using a constant range argument fails to compile:
It fails on both gcc 13.2 and clang 16.0.0
Error message (gcc):
The code fragment compiles just fine when using
auto span = ...
instead ofauto const span = ...
. Maybe I am missing something here, but I assume the intended behaviour is for it to also work with const arguments?Link to a complete example on compiler explorer