MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / reinterpret

Method reinterpret

include/cpp/marshal/View.hpp:80–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78template<class T>
79template<class K>
80inline cpp::marshal::View<K> cpp::marshal::View<T>::reinterpret() const
81{
82 auto newPtr = ::cpp::Pointer<K>(reinterpret_cast<K*>(ptr.ptr));
83 auto fromSize = sizeof(T);
84 auto toSize = sizeof(K);
85
86 if (toSize == fromSize)
87 {
88 return cpp::marshal::View<K>(newPtr, length);
89 }
90 if (toSize < fromSize)
91 {
92 return cpp::marshal::View<K>(newPtr, length * (fromSize / toSize));
93 }
94
95 auto shrink = static_cast<double>(fromSize) / toSize;
96 auto newLength = static_cast<int>(std::floor(length * shrink));
97
98 return cpp::marshal::View<K>(newPtr, newLength);
99}
100
101template<class T>
102inline int cpp::marshal::View<T>::compare(const View<T>& inRHS) const

Callers

nothing calls this directly

Calls 1

floorFunction · 0.85

Tested by

no test coverage detected