[flang] checkpoint
authorpeter klausler <pklausler@nvidia.com>
Mon, 4 Mar 2019 21:42:00 +0000 (13:42 -0800)
committerpeter klausler <pklausler@nvidia.com>
Mon, 4 Mar 2019 21:49:41 +0000 (13:49 -0800)
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
flang/lib/common/indirection.h

index 7b30025..919e200 100644 (file)
@@ -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                 |
 
index ec8a788..4cf822b 100644 (file)
@@ -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_