It seems I might be using std::valarray<_Tp>
s for some computational work (suppose _Tp
is uint64_t
). Unfortunately, the following hold:
- my code receives raw arrays -
uint64_t*
s and a length value - - I can't change signatures/APIs. They're
__restrict__
ed though. - std::valarray's constructor which takes a
_Tp*
and a length copies the entire array. - There do not seem to be methods for setting
std::valarray
's internal data; it's even private so you can't access it in a subclass.
So how do I break this Gordian knot and construct a valarray without copying my data?