You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/08/25 09:34:45 UTC
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #875: WIP: Disk space watchdog prototype
adamdebreceni commented on a change in pull request #875:
URL: https://github.com/apache/nifi-minifi-cpp/pull/875#discussion_r476314573
##########
File path: libminifi/include/utils/OptionalUtils.h
##########
@@ -37,11 +39,47 @@ optional<typename gsl_lite::remove_cvref<T>::type> optional_from_ptr(T&& obj) {
return obj == nullptr ? nullopt : optional<typename gsl_lite::remove_cvref<T>::type>{ std::forward<T>(obj) };
}
+template<typename>
+struct is_optional : std::false_type {};
+
+template<typename T>
+struct is_optional<optional<T>> : std::true_type {};
+
} // namespace utils
} // namespace minifi
} // namespace nifi
} // namespace apache
} // namespace org
+namespace nonstd {
+namespace optional_lite {
+
+namespace minifiutils = org::apache::nifi::minifi::utils;
+
+// map
+template<typename SourceType, typename F>
+auto operator|(const optional<SourceType>& o, F&& f) noexcept(noexcept(minifiutils::invoke(std::forward<F>(f), *o)))
+ -> optional<typename std::decay<decltype(minifiutils::invoke(std::forward<F>(f), *o))>::type> {
+ if (o.has_value()) {
+ return make_optional(minifiutils::invoke(std::forward<F>(f), *o));
+ } else {
+ return nullopt;
+ }
+}
+
+// bind
+template<typename SourceType, typename F>
+auto operator>>=(const optional<SourceType>& o, F&& f) noexcept(noexcept(minifiutils::invoke(std::forward<F>(f), *o)))
Review comment:
I'd rather we use the conventional `map` and `flatMap` names, could we create a custom `optional` class (with `map` and `flatMap`) extending the `nonstd::optional`, and make that available as `utils::optional`?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org