cpp-common/bt2c/fmt.hpp: use `wise_enum::string_type` in `EnableIfIsWiseEnum` definition
[babeltrace.git] / src / cpp-common / bt2 / borrowed-object-proxy.hpp
1 /*
2 * Copyright (c) 2023 Philippe Proulx <pproulx@efficios.com>
3 *
4 * SPDX-License-Identifier: MIT
5 */
6
7 #ifndef BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_PROXY_HPP
8 #define BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_PROXY_HPP
9
10 namespace bt2 {
11
12 /*
13 * A proxy containing a valid borrowed object instance of `ObjT` to make
14 * Something::operator->() work when only a libbabeltrace2 object
15 * pointer is available.
16 */
17 template <typename ObjT>
18 class BorrowedObjectProxy final
19 {
20 public:
21 explicit BorrowedObjectProxy(typename ObjT::LibObjPtr libObjPtr) noexcept : _mObj {libObjPtr}
22 {
23 }
24
25 const ObjT *operator->() const noexcept
26 {
27 return &_mObj;
28 }
29
30 private:
31 ObjT _mObj;
32 };
33
34 } /* namespace bt2 */
35
36 #endif /* BABELTRACE_CPP_COMMON_BT2_BORROWED_OBJECT_PROXY_HPP */
This page took 0.030199 seconds and 4 git commands to generate.