You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by bm...@apache.org on 2017/08/23 22:23:47 UTC
[04/13] mesos git commit: Introduced a CHECK_NOTNONE.
Introduced a CHECK_NOTNONE.
This is similar to glog's CHECK_NOTNULL.
Review: https://reviews.apache.org/r/61644
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/edd9b13a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/edd9b13a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/edd9b13a
Branch: refs/heads/master
Commit: edd9b13af889785eff2c56b09c1ebdae788bf1ce
Parents: a6e748c
Author: Benjamin Mahler <bm...@apache.org>
Authored: Thu Aug 10 18:04:48 2017 -0700
Committer: Benjamin Mahler <bm...@apache.org>
Committed: Wed Aug 23 15:09:07 2017 -0700
----------------------------------------------------------------------
3rdparty/stout/include/stout/check.hpp | 50 ++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/edd9b13a/3rdparty/stout/include/stout/check.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/check.hpp b/3rdparty/stout/include/stout/check.hpp
index e3cabd4..6a33579 100644
--- a/3rdparty/stout/include/stout/check.hpp
+++ b/3rdparty/stout/include/stout/check.hpp
@@ -53,10 +53,58 @@
CHECK_STATE(CHECK_ERROR, _check_error, expression)
-// Private structs/functions used for CHECK_*.
+// A private helper for CHECK_NOTNONE which is similar to the
+// CHECK_NOTNULL provided by glog.
+template <typename T>
+T&& _check_not_none(
+ const char* file,
+ int line,
+ const char* message,
+ Option<T>&& t) {
+ if (t.isNone()) {
+ google::LogMessageFatal(file, line, new std::string(message));
+ }
+ return std::move(t).get();
+}
+
+
+template <typename T>
+T& _check_not_none(
+ const char* file,
+ int line,
+ const char* message,
+ Option<T>& t) {
+ if (t.isNone()) {
+ google::LogMessageFatal(file, line, new std::string(message));
+ }
+ return t.get();
+}
template <typename T>
+const T& _check_not_none(
+ const char* file,
+ int line,
+ const char* message,
+ const Option<T>& t) {
+ if (t.isNone()) {
+ google::LogMessageFatal(file, line, new std::string(message));
+ }
+ return t.get();
+}
+
+
+#define CHECK_NOTNONE(expression) \
+ _check_not_none( \
+ __FILE__, \
+ __LINE__, \
+ "'" #expression "' Must be SOME", \
+ (expression))
+
+
+// Private structs/functions used for CHECK_*.
+
+template <typename T>
Option<Error> _check_some(const Option<T>& o)
{
if (o.isNone()) {