Sonde v1.1.0
Embeddable Model Context Protocol server for Qt applications
Loading...
Searching...
No Matches
Sonde::PrivatePtr< T > Class Template Reference

Owns a class's private part, like std::unique_ptr, but a const owner only gets a const pointer, like std::experimental::propagate_const (which MSVC lacks). More...

#include <privateptr.h>

Public Member Functions

 PrivatePtr (T *p=nullptr) noexcept
 Takes ownership of p.
 PrivatePtr (std::unique_ptr< T > p) noexcept
 Takes ownership of what p owns.
 PrivatePtr (PrivatePtr &&) noexcept=default
 Moves ownership.
PrivatePtr & operator= (PrivatePtr &&) noexcept=default
 Moves ownership.
 PrivatePtr (const PrivatePtr &)=delete
 Not copyable.
PrivatePtr & operator= (const PrivatePtr &)=delete
 Not copyable.
 ~PrivatePtr ()=default
 Destroys the private part.
T * get () noexcept
 The private part.
const T * get () const noexcept
 The private part, const.
T * operator-> () noexcept
 The private part.
const T * operator-> () const noexcept
 The private part, const.
T & operator* () noexcept
 The private part.
const T & operator* () const noexcept
 The private part, const.
 operator bool () const noexcept
 Whether it owns anything.
void reset (T *p=nullptr) noexcept
 Destroys what it owns, and owns p instead.

Private Attributes

std::unique_ptr< T > m_p
 What it owns.

Detailed Description

template<typename T>
class Sonde::PrivatePtr< T >

Owns a class's private part, like std::unique_ptr, but a const owner only gets a const pointer, like std::experimental::propagate_const (which MSVC lacks).

So a const member function can't change the private part by accident.

Public only because the layouts of public classes use it. The owner must declare its destructor out of line, where T is complete.


The documentation for this class was generated from the following file: