From 752721d3a8e018d1ea48b8f4979779085293a314 Mon Sep 17 00:00:00 2001 From: peter klausler Date: Mon, 4 Mar 2019 13:42:00 -0800 Subject: [PATCH] [flang] checkpoint Original-commit: flang-compiler/f18@65abebd838ef6b20960f69595709db55f3e5a9b7 Reviewed-on: https://github.com/flang-compiler/f18/pull/314 Tree-same-pre-rewrite: false --- flang/documentation/C++style.md | 2 ++ flang/lib/common/indirection.h | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/flang/documentation/C++style.md b/flang/documentation/C++style.md index 7b30025..919e200 100644 --- a/flang/documentation/C++style.md +++ b/flang/documentation/C++style.md @@ -199,6 +199,7 @@ for use with forward-defined types than `std::unique_ptr<>` is. Null by default, optionally copyable, reassignable. Does not have direct means for allocating data, and inconveniently requires the definition of an external destructor. +* `OwningReference<>`: A non-nullable `OwningPointer<>`. * `Indirection<>`: A non-nullable pointer with ownership and optional deep copy semantics; reassignable. Often better than a reference (due to ownership) or `std::unique_ptr<>` @@ -220,6 +221,7 @@ A feature matrix: | `unique_ptr<>` | yes | yes | yes | yes | no | no | | `shared_ptr<>` | yes | yes | yes | yes | shallowly | no | | `OwningPointer<>` | yes | yes | yes | yes | optionally deeply | yes | +| `OwningReference<>` | no | yes | yes | yes | optionally deeply | yes | | `Indirection<>` | no | n/a | yes | yes | optionally deeply | no | | `CountedReference<>` | yes | yes | yes | yes | shallowly | no | diff --git a/flang/lib/common/indirection.h b/flang/lib/common/indirection.h index ec8a788..4cf822b 100644 --- a/flang/lib/common/indirection.h +++ b/flang/lib/common/indirection.h @@ -53,6 +53,9 @@ public: that.p_ = tmp; return *this; } + + A &value() { return *p_; } + const A &value() const { return *p_; } A &operator*() { return *p_; } const A &operator*() const { return *p_; } A *operator->() { return p_; } @@ -103,6 +106,9 @@ public: that.p_ = tmp; return *this; } + + A &value() { return *p_; } + const A &value() const { return *p_; } A &operator*() { return *p_; } const A &operator*() const { return *p_; } A *operator->() { return p_; } @@ -208,7 +214,6 @@ private: return *this; \ } \ } -} #define DEFINE_OWNING_POINTER_COPY_FUNCTIONS(A) \ DEFINE_OWNING_POINTER_COPY_CONSTRUCTORS(A) \ @@ -216,5 +221,5 @@ private: #define DEFINE_OWNING_POINTER_SPECIAL_FUNCTIONS(A) \ DEFINE_OWNING_POINTER_DESTRUCTOR(A) \ DEFINE_OWNING_POINTER_COPY_FUNCTIONS(A) - +} #endif // FORTRAN_COMMON_INDIRECTION_H_ -- 2.7.4