Closed PerretB closed 6 years ago
Does it work if you make your view const as well (e.g.
const auto a2 = xt::view(a1, 1, xt::range(1,2));
yes !
I'm quite a c++ newbie, but shouldn't have the compiler deduced the const
in this case ?
Yes, it's something that we can probably add. We can discuss this tomorrow.
I'm quite a c++ newbie, but shouldn't have the compiler deduced the const in this case ?
xview
provides two overloads of operator()
, one that is const and returns a const reference, and another non const that returns a non const reference.
When you write a2(0)
, the compiler considers the declaration of a2
to decide wich overload of operator()
to call. In Your case, since a2
is not declared as const, the non const version is called (and that's the standard behavior).
The problem here is that the non const overload of operator()
should return a const reference when the underlying expression is const.
Thank you for the explanation and the very fast answer
Hi,
there seems to be a problem that prevents accessing to the elements of a view on a const array with the
operator()
. Exemple :My configuration is:
Thanks for all the amazing work !