Skip to content

Commit

Permalink
(draft) constexpr error diagnostic
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuzu-Typ committed Feb 4, 2024
1 parent 8f247cb commit b3334f9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions PyGLM/types/typeobjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,24 @@ static constexpr ptrdiff_t PyGLMTypeObjectArrayOffsetVec() {
}
}
}

constexpr auto size = sizeof(T);
if constexpr (size == 1) {
throw std::logic_error("Error: Unsupported type of size 1 byte.");
}
else if constexpr (size == 2) {
throw std::logic_error("Error: Unsupported type of size 2 bytes.");
}
else if constexpr (size == 4) {
throw std::logic_error("Error: Unsupported type of size 4 bytes.");
}
else if constexpr (size == 8) {
throw std::logic_error("Error: Unsupported type of size 8 bytes.");
}
else {
// Fallback for an unexpected size
throw std::logic_error("Error: Unsupported type of an unexpected size.");
}
}

template<int C, int R, typename T>
Expand Down

0 comments on commit b3334f9

Please sign in to comment.