File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change 5252
5353#include < array>
5454#include < cmath>
55+ #include < cstring>
5556#ifndef __SYCL_DEVICE_ONLY__
5657#include < cfenv>
5758#endif
@@ -579,11 +580,16 @@ template <typename Type, int NumElements> class vec {
579580 return Result;
580581 }
581582
582- template <typename asT>
583- typename std::enable_if<sizeof (asT) == sizeof (DataType), asT>::type
584- as () const {
583+ template <typename asT> asT as () const {
584+ static_assert ((sizeof (*this ) == sizeof (asT)),
585+ " The new SYCL vec type must have the same storage size in "
586+ " bytes as this SYCL vec" );
587+ static_assert (
588+ detail::is_contained<asT, detail::gtl::vector_basic_list>::value,
589+ " asT must be SYCL vec of a different element type and "
590+ " number of elements specified by asT" );
585591 asT Result;
586- * static_cast <DataType *>( static_cast < void *>( &Result.m_Data )) = m_Data;
592+ std::memcpy ( &Result.m_Data , &m_Data, sizeof ( decltype (Result. m_Data ))) ;
587593 return Result;
588594 }
589595
You can’t perform that action at this time.
0 commit comments