MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / arrayCast

Function arrayCast

Sources/Shared/Containers/ArrayView.h:649–656  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

647 and the total byte size doesn't change.
648 */
649 template<class U, class T> ArrayView<U> arrayCast(ArrayView<T> view) {
650 static_assert(std::is_standard_layout<T>::value, "The source type is not standard layout");
651 static_assert(std::is_standard_layout<U>::value, "The target type is not standard layout");
652 const std::size_t size = view.size() * sizeof(T) / sizeof(U);
653 DEATH_ASSERT(size * sizeof(U) == view.size() * sizeof(T),
654 ("Cannot reinterpret {} {}-byte items into a {}-byte type", view.size(), sizeof(T), sizeof(U)), {});
655 return { reinterpret_cast<U*>(view.begin()), size };
656 }
657
658 /** @relatesalso ArrayView
659 @brief Reinterpret-cast a void array view

Callers

nothing calls this directly

Calls 4

DEATH_ASSERTFunction · 0.85
sizeMethod · 0.45
beginMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected