Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(294)

Unified Diff: include/v8.h

Issue 958053003: Removed funky Maybe constructor and made fields private. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index a38dc0a68fbf2686f67ee72db85ce41bd2d36d98..9b7c164d0c3c8e85370b5d5a8b104024d2de5fc2 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -5726,14 +5726,11 @@ class V8_EXPORT V8 {
/**
* A simple Maybe type, representing an object which may or may not have a
- * value.
+ * value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
*/
template <class T>
class Maybe {
public:
- // TODO(dcarney): remove this constructor, it makes no sense.
- Maybe(bool has, const T& t) : has_value(has), value(t) {}
-
V8_INLINE bool IsJust() const { return has_value; }
V8_INLINE T FromJust() const {
@@ -5747,18 +5744,26 @@ class Maybe {
return has_value ? value : default_value;
}
- // TODO(dcarney): make private.
+ V8_INLINE bool operator==(const Maybe& other) const {
+ return (IsJust() == other.IsJust()) &&
+ (!IsJust() || FromJust() == other.FromJust());
+ }
+
+ V8_INLINE bool operator!=(const Maybe& other) const {
+ return !operator==(other);
+ }
+
+ private:
+ Maybe() : has_value(false) {}
+ explicit Maybe(const T& t) : has_value(true), value(t) {}
+
bool has_value;
T value;
- private:
template <class U>
friend Maybe<U> Nothing();
template <class U>
friend Maybe<U> Just(const U& u);
-
- Maybe() : has_value(false) {}
- explicit Maybe(const T& t) : has_value(true), value(t) {}
};
« no previous file with comments | « no previous file | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698