add Scalar<T> + cast to T
This commit is contained in:
parent
714eecd663
commit
6e1da5eed3
1 changed files with 12 additions and 0 deletions
|
@ -51,6 +51,8 @@ namespace MultiArrayTools
|
||||||
virtual const T* data() const override;
|
virtual const T* data() const override;
|
||||||
virtual T* data() override;
|
virtual T* data() override;
|
||||||
|
|
||||||
|
operator T() const;
|
||||||
|
|
||||||
template <typename U, class... SRanges2>
|
template <typename U, class... SRanges2>
|
||||||
friend class MultiArray;
|
friend class MultiArray;
|
||||||
|
|
||||||
|
@ -58,6 +60,9 @@ namespace MultiArrayTools
|
||||||
std::vector<T> mCont;
|
std::vector<T> mCont;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
using Scalar = MultiArray<T>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ========================= *
|
/* ========================= *
|
||||||
|
@ -193,6 +198,13 @@ namespace MultiArrayTools
|
||||||
{
|
{
|
||||||
return mCont.data();
|
return mCont.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, class... SRanges>
|
||||||
|
MultiArray<T,SRanges...>::operator T() const
|
||||||
|
{
|
||||||
|
static_assert( sizeof...(SRanges) == 0, "try to cast non-scalar type into scalar" );
|
||||||
|
return mCont[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue