diff --git a/src/include/multi_array.h b/src/include/multi_array.h index 014976c..120877c 100644 --- a/src/include/multi_array.h +++ b/src/include/multi_array.h @@ -50,6 +50,8 @@ namespace MultiArrayTools virtual const T* data() const override; virtual T* data() override; + + operator T() const; template friend class MultiArray; @@ -57,6 +59,9 @@ namespace MultiArrayTools private: std::vector mCont; }; + + template + using Scalar = MultiArray; } @@ -193,6 +198,13 @@ namespace MultiArrayTools { return mCont.data(); } + + template + MultiArray::operator T() const + { + static_assert( sizeof...(SRanges) == 0, "try to cast non-scalar type into scalar" ); + return mCont[0]; + } } #endif