#ifndef __ma_conversions_h__ #define __ma_conversions_h__ #include "multi_array.h" #include "slice.h" namespace MultiArrayTools { namespace ConversionSizes { template struct OrigSize { template struct FromTo { static void check() { static_assert( not N % (sizeof(T) / sizeof(C)), "conversion does not fit" ); } static constexpr size_t SIZE = N * sizeof(T) / sizeof(C); }; }; template <> struct OrigSize<-1> { template struct FromTo { static void check() {} static constexpr size_t SIZE = -1; }; }; } namespace { template using SC = ConversionSizes::OrigSize::template FromTo; template using SCR = SC; template using SCRR = GenSingleRange; } template Slice> tcast(MultiArray& ma) { return Slice> ( ma.range()->space(), reinterpret_cast( ma.data() ) ); } template ConstSlice> tcast(const MultiArray& ma) { return ConstSlice> ( ma.range()->space(), reinterpret_cast( ma.data() ) ); } } #endif