*
* 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
};
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.
*
* 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.");
*/
std::size_t hash() const noexcept
{
- return std::hash<_LibObjPtr> {}(_mLibObjPtr);
+ return std::hash<LibObjPtr> {}(_mLibObjPtr);
}
/*
}
/* Wrapped libbabeltrace2 object pointer */
- _LibObjPtr libObjPtr() const noexcept
+ LibObjPtr libObjPtr() const noexcept
{
return _mLibObjPtr;
}
private:
- _LibObjPtr _mLibObjPtr;
+ LibObjPtr _mLibObjPtr;
};
} /* namespace bt2 */