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 2015/06/01 21:53:46 UTC

mesos git commit: Add non-const reference version of Option::get.

Repository: mesos
Updated Branches:
  refs/heads/master c60b2ad21 -> 08f00e786


Add non-const reference version of Option<T>::get.

Review: https://reviews.apache.org/r/34529


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

Branch: refs/heads/master
Commit: 08f00e786fd6a4548878c065f75a0e42110aaa10
Parents: c60b2ad
Author: Mark Wang <ma...@gmail.com>
Authored: Mon Jun 1 12:46:03 2015 -0700
Committer: Benjamin Mahler <be...@gmail.com>
Committed: Mon Jun 1 12:53:43 2015 -0700

----------------------------------------------------------------------
 .../libprocess/3rdparty/stout/include/stout/option.hpp   |  1 +
 .../libprocess/3rdparty/stout/tests/option_tests.cpp     | 11 +++++++++++
 2 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/08f00e78/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 8aa59f1..8d5217a 100644
--- a/3rdparty/libprocess/3rdparty/stout/include/stout/option.hpp
+++ b/3rdparty/libprocess/3rdparty/stout/include/stout/option.hpp
@@ -101,6 +101,7 @@ public:
   bool isNone() const { return state == NONE; }
 
   const T& get() const { assert(isSome()); return t; }
+  T& get() { assert(isSome()); return t; }
 
   // This must return a copy to avoid returning a reference to a temporary.
   T get(const T& _t) const { return isNone() ? _t : t; }

http://git-wip-us.apache.org/repos/asf/mesos/blob/08f00e78/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 7ae3b8f..f1ae80a 100644
--- a/3rdparty/libprocess/3rdparty/stout/tests/option_tests.cpp
+++ b/3rdparty/libprocess/3rdparty/stout/tests/option_tests.cpp
@@ -1,9 +1,12 @@
 #include <gmock/gmock.h>
 
+#include <string>
 #include <stout/gtest.hpp>
 #include <stout/none.hpp>
 #include <stout/option.hpp>
 
+using std::string;
+
 TEST(OptionTest, Min)
 {
   Option<int> none1 = None();
@@ -90,3 +93,11 @@ TEST(OptionTest, Comparison)
   EXPECT_NE(someNone, noneNone);
   EXPECT_NE(noneNone, someNone);
 }
+
+
+TEST(OptionTest, NonConstReference)
+{
+  Option<string> s = string("hello");
+  s.get() += " world";
+  EXPECT_EQ("hello world", s.get());
+}