gemini-code-assist[bot] commented on code in PR #85:
URL: https://github.com/apache/tvm-ffi/pull/85#discussion_r2401321181
##########
include/tvm/ffi/type_traits.h:
##########
@@ -301,10 +301,23 @@ struct TypeTraits<Int,
std::enable_if_t<std::is_integral_v<Int>>> : public TypeT
TVM_FFI_INLINE static std::string TypeStr() { return
StaticTypeKey::kTVMFFIInt; }
};
+// --- Add this helper for GCC 8.x ---
+template<typename T, bool = std::is_enum_v<T>>
+struct safe_underlying_type { using type = void; };
+
+template<typename T>
+struct safe_underlying_type <T, true> {
+ using type = typename std::underlying_type<T>::type;
+};
+
+template<typename T>
+using safe_underlying_type_t = typename safe_underlying_type<T>::type;
+// --- end helper ---
Review Comment:

The comments `--- Add this helper for GCC 8.x ---` and `--- end helper ---`
are informal and don't fully explain the rationale behind this helper. For
improved code clarity and long-term maintainability, it's better to use a more
descriptive comment that explains *why* this helper is necessary, following the
Doxygen style used elsewhere in the file.
```c
/*!
* \brief Helper to safely get the underlying type of an enum.
*
* This is needed to support SFINAE contexts on some compilers (e.g., GCC
8.x),
* where `std::underlying_type` on a non-enum type can cause a hard
compilation error
* instead of a substitution failure.
*/
template <typename T, bool = std::is_enum_v<T>>
struct safe_underlying_type {
using type = void;
};
template <typename T>
struct safe_underlying_type<T, true> {
using type = typename std::underlying_type<T>::type;
};
template <typename T>
using safe_underlying_type_t = typename safe_underlying_type<T>::type;
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]