Commit d2c77acc authored by wenjh's avatar wenjh
Browse files

Fix out-of-bounds issues for types struct in common/common.h


Signed-off-by: wenjh's avatarwenjh <wenjh@sugon.com>
parent 284d3f6f
...@@ -457,7 +457,9 @@ struct TypeInfo { ...@@ -457,7 +457,9 @@ struct TypeInfo {
struct Helper { struct Helper {
constexpr static DType getType() { constexpr static DType getType() {
constexpr int i = static_cast<int>(current); constexpr int i = static_cast<int>(current);
if (std::is_same<U, typename std::tuple_element<i, types>::type>::value) { if constexpr (i >= std::tuple_size_v<types>) {
return DType::kNumTypes;
} else if (std::is_same<U, typename std::tuple_element<i, types>::type>::value) {
return current; return current;
} else { } else {
return Helper<U, static_cast<DType>(i + 1)>::getType(); return Helper<U, static_cast<DType>(i + 1)>::getType();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment