tqchen opened a new pull request, #596: URL: https://github.com/apache/tvm-ffi/pull/596
## Summary The four type-erased FFI value containers (`ffi::Any`, `ffi::ObjectRef`, `ffi::Variant<Ts...>`, `ffi::Optional<T>`) have no `operator<<` for `std::ostream`, requiring manual `.ToString()` / `ReprPrint()` calls. This PR adds four inline overloads in `include/tvm/ffi/extra/dataclass.h` that delegate to the existing `ReprPrint(Any)` machinery, so `std::cout << x` and `LOG(INFO) << x` just work. - `operator<<(ostream&, const Any&)` — delegates to `ReprPrint(value)` - `operator<<(ostream&, const ObjectRef&)` — delegates to `ReprPrint(Any(value))`; derived types still print their type-specific repr via runtime `type_index` dispatch - `operator<<(ostream&, const Variant<Ts...>&)` — delegates to `ReprPrint(Any(value))` - `operator<<(ostream&, const Optional<T>&)` — prints `"None"` for empty (Python convention), otherwise `ReprPrint(Any(value))` Pre-existing `String` and `Shape` `operator<<` overloads are unaffected: `Shape` (a derived `ObjectRef`) wins over the generic `const ObjectRef&` overload via overload resolution; `String` is not an `ObjectRef` subclass and has no conflict. -- 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]
