| 78 | template<class T> |
| 79 | template<class K> |
| 80 | inline 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 | |
| 101 | template<class T> |
| 102 | inline int cpp::marshal::View<T>::compare(const View<T>& inRHS) const |