.gitignore: add some more IDE / tools related file
[babeltrace.git] / src / cpp-common / bt2 / borrowed-object.hpp
index 6b1f6e571d3110f8dd8e4b6c8f22da8d43295c27..fbfd5b10c35bbed058c2d6680d68eb752d03643a 100644 (file)
@@ -25,6 +25,9 @@ namespace bt2 {
  *
  * The user of a borrowed object, including methods of a derived class,
  * can call libObjPtr() to access the libbabeltrace2 object pointer.
+ *
+ * You may only build a borrowed object with a pointer which isn't
+ * `nullptr`. See `bt2::OptionalBorrowedObject` for an optional version.
  */
 template <typename LibObjT>
 class BorrowedObject
@@ -70,27 +73,28 @@ private:
     };
 
 protected:
-    /* libbabeltrace2 object pointer */
-    using _LibObjPtr = LibObjT *;
-
     /* This complete borrowed object */
     using _ThisBorrowedObject = BorrowedObject<LibObjT>;
 
+public:
+    /* libbabeltrace2 object */
+    using LibObj = LibObjT;
+
+    /* libbabeltrace2 object pointer */
+    using LibObjPtr = LibObjT *;
+
+protected:
     /*
      * Builds a borrowed object to wrap the libbabeltrace2 object
      * pointer `libObjPtr`.
      *
      * `libObjPtr` must not be `nullptr`.
      */
-    explicit BorrowedObject(const _LibObjPtr libObjPtr) noexcept : _mLibObjPtr {libObjPtr}
+    explicit BorrowedObject(const LibObjPtr libObjPtr) noexcept : _mLibObjPtr {libObjPtr}
     {
         BT_ASSERT_DBG(libObjPtr);
     }
 
-    /* Default copy operations */
-    BorrowedObject(const BorrowedObject&) noexcept = default;
-    BorrowedObject& operator=(const BorrowedObject&) noexcept = default;
-
     /*
      * Generic "copy" constructor.
      *
@@ -126,7 +130,7 @@ protected:
      * context in the compiler error message.
      */
     template <typename OtherLibObjT>
-    _ThisBorrowedObject& operator=(const BorrowedObject<OtherLibObjT>& other) noexcept
+    _ThisBorrowedObject operator=(const BorrowedObject<OtherLibObjT>& other) noexcept
     {
         static_assert(_AssignableFromConst<OtherLibObjT>::val,
                       "Don't assign a non-const wrapper from a const wrapper.");
@@ -142,7 +146,7 @@ public:
      */
     std::size_t hash() const noexcept
     {
-        return std::hash<_LibObjPtr> {}(_mLibObjPtr);
+        return std::hash<LibObjPtr> {}(_mLibObjPtr);
     }
 
     /*
@@ -155,13 +159,13 @@ public:
     }
 
     /* Wrapped libbabeltrace2 object pointer */
-    _LibObjPtr libObjPtr() const noexcept
+    LibObjPtr libObjPtr() const noexcept
     {
         return _mLibObjPtr;
     }
 
 private:
-    _LibObjPtr _mLibObjPtr;
+    LibObjPtr _mLibObjPtr;
 };
 
 } /* namespace bt2 */
This page took 0.032788 seconds and 4 git commands to generate.