tkonolige commented on a change in pull request #8821:
URL: https://github.com/apache/tvm/pull/8821#discussion_r694353380
##########
File path: src/runtime/hexagon/sim/hexagon_device_sim.cc
##########
@@ -84,6 +82,34 @@ std::unique_ptr<T> make_unique(size_t size) {
return std::unique_ptr<T>(new U[size]());
}
+// Replacement for llvm::Optional.
+template <typename T>
+class Optional {
+ public:
+ Optional() : has_value(false) {}
+ Optional(const T& val) : value(val), has_value(true) {} // NOLINT(*)
+ Optional(T&& val) : value(val), has_value(true) {} // NOLINT(*)
+
+ bool hasValue() const { return has_value; }
+ operator bool() const { return hasValue(); }
+ T operator*() const {
+ ICHECK(has_value) << "value not set";
+ return value;
+ }
+ const T* operator->() const {
+ ICHECK(has_value) << "value not set";
+ return &value;
+ }
+ T* operator->() {
+ ICHECK(has_value) << "value not set";
+ return &value;
+ }
+
+ private:
+ T value;
+ bool has_value;
+};
+
Review comment:
dmlc has an optional type, maybe use that instead?
--
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]