2 * Copyright (C) 2024 Jérémie Galarneau <jeremie.galarneau@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_REFERENCE_H
9 #define LTTNG_REFERENCE_H
16 template <typename ReferencedType, typename CustomDeleter>
17 class non_copyable_reference {
19 explicit non_copyable_reference(ReferencedType& instance) noexcept : _value(&instance)
23 non_copyable_reference(non_copyable_reference&& other) noexcept : _value(other._value)
25 other._value = nullptr;
28 non_copyable_reference() = delete;
29 non_copyable_reference(const non_copyable_reference&) = delete;
30 non_copyable_reference& operator=(non_copyable_reference&&) = delete;
31 non_copyable_reference& operator=(const non_copyable_reference&) = delete;
33 ReferencedType& get() const noexcept
38 ReferencedType *operator->() const noexcept
43 ReferencedType& operator*() const noexcept
48 ~non_copyable_reference()
54 typename CustomDeleter::deleter del;
59 ReferencedType *_value = nullptr;
62 } /* namespace lttng */
64 #endif /* LTTNG_REFERENCE_H */