Sonde
v1.1.0
Embeddable Model Context Protocol server for Qt applications
Toggle main menu visibility
Loading...
Searching...
No Matches
privateptr.h
Go to the documentation of this file.
1
#pragma once
2
6
7
#include <memory>
8
#include <utility>
9
10
namespace
Sonde
{
11
18
template
<
typename
T>
19
class
PrivatePtr
20
{
21
public
:
23
explicit
PrivatePtr
(T *p =
nullptr
) noexcept :
m_p
(p) { }
25
explicit
PrivatePtr
(std::unique_ptr<T> p) noexcept :
m_p
(std::move(p)) { }
26
27
PrivatePtr
(
PrivatePtr
&&) noexcept = default;
28
PrivatePtr
&operator=(
PrivatePtr
&&) noexcept = default;
29
PrivatePtr
(const
PrivatePtr
&) = delete;
30
PrivatePtr
&operator=(const
PrivatePtr
&) = delete;
31
~
PrivatePtr
() = default;
32
34
T *
get
() noexcept {
return
m_p
.get(); }
36
const
T *
get
() const noexcept {
return
m_p
.get(); }
38
T *
operator->
() noexcept {
return
m_p
.get(); }
40
const
T *
operator->
() const noexcept {
return
m_p
.get(); }
42
T &
operator*
() noexcept {
return
*
m_p
; }
44
const
T &
operator*
() const noexcept {
return
*
m_p
; }
46
explicit
operator
bool() const noexcept {
return
m_p
!=
nullptr
; }
47
49
void
reset
(T *p =
nullptr
) noexcept {
m_p
.reset(p); }
50
51
private
:
52
std::unique_ptr<T>
m_p
;
53
};
54
55
}
// namespace Sonde
Sonde::PrivatePtr::get
T * get() noexcept
The private part.
Definition
privateptr.h:34
Sonde::PrivatePtr::PrivatePtr
PrivatePtr(T *p=nullptr) noexcept
Takes ownership of p.
Definition
privateptr.h:23
Sonde::PrivatePtr::operator->
T * operator->() noexcept
The private part.
Definition
privateptr.h:38
Sonde::PrivatePtr::m_p
std::unique_ptr< T > m_p
What it owns.
Definition
privateptr.h:52
Sonde::PrivatePtr::PrivatePtr
PrivatePtr(std::unique_ptr< T > p) noexcept
Takes ownership of what p owns.
Definition
privateptr.h:25
Sonde::PrivatePtr::get
const T * get() const noexcept
The private part, const.
Definition
privateptr.h:36
Sonde::PrivatePtr::operator*
T & operator*() noexcept
The private part.
Definition
privateptr.h:42
Sonde::PrivatePtr::operator->
const T * operator->() const noexcept
The private part, const.
Definition
privateptr.h:40
Sonde::PrivatePtr::PrivatePtr
PrivatePtr(PrivatePtr &&) noexcept=default
Moves ownership.
Sonde::PrivatePtr::operator*
const T & operator*() const noexcept
The private part, const.
Definition
privateptr.h:44
Sonde::PrivatePtr::reset
void reset(T *p=nullptr) noexcept
Destroys what it owns, and owns p instead.
Definition
privateptr.h:49
Sonde
Embeddable Model Context Protocol server for Qt applications.
Definition
dispatch.cpp:10
src
core
sonde
privateptr.h
Generated by
1.18.0