You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2013/12/12 22:54:11 UTC

git commit: Added more overloaded functions of min/max in Option.

Updated Branches:
  refs/heads/master 360903ff3 -> 280895fbb


Added more overloaded functions of min/max in Option.

From: Jie Yu <yu...@gmail.com>
Review: https://reviews.apache.org/r/16225


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/280895fb
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/280895fb
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/280895fb

Branch: refs/heads/master
Commit: 280895fbbf4082a2133605d8e71bad17b39baf39
Parents: 360903f
Author: Benjamin Hindman <be...@gmail.com>
Authored: Thu Dec 12 13:53:11 2013 -0800
Committer: Benjamin Hindman <be...@gmail.com>
Committed: Thu Dec 12 13:53:11 2013 -0800

----------------------------------------------------------------------
 .../3rdparty/stout/include/stout/option.hpp     | 28 ++++++++++++++++++++
 .../3rdparty/stout/tests/option_tests.cpp       | 18 +++++++++++++
 2 files changed, 46 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/280895fb/3rdparty/libprocess/3rdparty/stout/include/stout/option.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/include/stout/option.hpp b/3rdparty/libprocess/3rdparty/stout/include/stout/option.hpp
index f93bc15..f12c0ca 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/option.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/option.hpp
@@ -112,6 +112,20 @@ Option<T> min(const Option<T>& left, const Option<T>& right)
 
 
 template <typename T>
+Option<T> min(const Option<T>& left, const T& right)
+{
+  return min(left, Option<T>(right));
+}
+
+
+template <typename T>
+Option<T> min(const T& left, const Option<T>& right)
+{
+  return min(Option<T>(left), right);
+}
+
+
+template <typename T>
 Option<T> max(const Option<T>& left, const Option<T>& right)
 {
   if (left.isSome() && right.isSome()) {
@@ -125,4 +139,18 @@ Option<T> max(const Option<T>& left, const Option<T>& right)
   }
 }
 
+
+template <typename T>
+Option<T> max(const Option<T>& left, const T& right)
+{
+  return max(left, Option<T>(right));
+}
+
+
+template <typename T>
+Option<T> max(const T& left, const Option<T>& right)
+{
+  return max(Option<T>(left), right);
+}
+
 #endif // __STOUT_OPTION_HPP__

http://git-wip-us.apache.org/repos/asf/mesos/blob/280895fb/3rdparty/libprocess/3rdparty/stout/tests/option_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/stout/tests/option_tests.cpp b/3rdparty/libprocess/3rdparty/stout/tests/option_tests.cpp
index be56d1f..bda0610 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/option_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/option_tests.cpp
@@ -10,6 +10,7 @@ TEST(OptionTest, Min)
   Option<int> none2 = None();
   Option<int> value1 = 10;
   Option<int> value2 = 20;
+  int value3 = 15;
 
   Option<int> result = min(none1, none2);
   ASSERT_NONE(result);
@@ -25,6 +26,14 @@ TEST(OptionTest, Min)
   result = min(value1, value2);
   ASSERT_SOME(result);
   EXPECT_EQ(10, result.get());
+
+  result = min(none1, value3);
+  ASSERT_SOME(result);
+  EXPECT_EQ(15, result.get());
+
+  result = min(value3, value1);
+  ASSERT_SOME(result);
+  EXPECT_EQ(10, result.get());
 }
 
 
@@ -34,6 +43,7 @@ TEST(OptionTest, Max)
   Option<int> none2 = None();
   Option<int> value1 = 10;
   Option<int> value2 = 20;
+  int value3 = 15;
 
   Option<int> result = max(none1, none2);
   ASSERT_NONE(result);
@@ -49,4 +59,12 @@ TEST(OptionTest, Max)
   result = max(value1, value2);
   ASSERT_SOME(result);
   EXPECT_EQ(20, result.get());
+
+  result = max(none1, value3);
+  ASSERT_SOME(result);
+  EXPECT_EQ(15, result.get());
+
+  result = max(value3, value2);
+  ASSERT_SOME(result);
+  EXPECT_EQ(20, result.get());
 }