libzypp 17.37.10

zypp::RW_pointer< D, DTraits > Struct Template Reference

Wrapper for `const` correct access via Smart pointer types. More...

`#include <zypp-core/base/PtrTypes.h>`

## Public Types
using | PtrType = typename DTraits::PtrType
using | constPtrType = typename DTraits::constPtrType

## Public Member Functions
| RW_pointer ()
| RW_pointer (const RW_pointer &)=default
| RW_pointer (RW_pointer &&)=default
RW_pointer & | operator= (const RW_pointer &)=default
RW_pointer & | operator= (RW_pointer &&)=default
| RW_pointer (std::nullptr_t)
| RW_pointer (typename PtrType::element_type *dptr)
| RW_pointer (PtrType dptr)
RW_pointer & | operator= (std::nullptr_t)
void | reset ()
void | reset (typename PtrType::element_type *dptr)
void | swap (RW_pointer &rhs) noexcept
void | swap (PtrType &rhs) noexcept
| operator bool () const
const D & | operator* () const
const D * | operator-> () const
const D * | get () const
D & | operator* ()
D * | operator-> ()
D * | get ()
bool | unique () const
long | use_count () const
constPtrType | getPtr () const
PtrType | getPtr ()
constPtrType | cgetPtr ()

## Private Attributes
PtrType | _dptr

## Related Symbols
(Note that these are not member symbols.)
template<class D, class DPtr>
std::ostream & | operator<< (std::ostream &str, const RW_pointer< D, DPtr > &obj)
| Stream output.
template<class D, class DPtr>
bool | operator== (const RW_pointer< D, DPtr > &lhs, const RW_pointer< D, DPtr > &rhs)
template<class D, class DPtr>
bool | operator== (const RW_pointer< D, DPtr > &lhs, const typename DPtr::PtrType &rhs)
template<class D, class DPtr>
bool | operator== (const typename DPtr::PtrType &lhs, const RW_pointer< D, DPtr > &rhs)
template<class D, class DPtr>
bool | operator== (const RW_pointer< D, DPtr > &lhs, const typename DPtr::constPtrType &rhs)
template<class D, class DPtr>
bool | operator== (const typename DPtr::constPtrType &lhs, const RW_pointer< D, DPtr > &rhs)
template<class D, class DPtr>
bool | operator== (const RW_pointer< D, DPtr > &lhs, std::nullptr_t)
template<class D, class DPtr>
bool | operator== (std::nullptr_t, const RW_pointer< D, DPtr > &rhs)
template<class D, class DPtr>
bool | operator!= (const RW_pointer< D, DPtr > &lhs, const RW_pointer< D, DPtr > &rhs)
template<class D, class DPtr>
bool | operator!= (const RW_pointer< D, DPtr > &lhs, const typename DPtr::PtrType &rhs)
template<class D, class DPtr>
bool | operator!= (const typename DPtr::PtrType &lhs, const RW_pointer< D, DPtr > &rhs)
template<class D, class DPtr>
bool | operator!= (const RW_pointer< D, DPtr > &lhs, const typename DPtr::constPtrType &rhs)
template<class D, class DPtr>
bool | operator!= (const typename DPtr::constPtrType &lhs, const RW_pointer< D, DPtr > &rhs)
template<class D, class DPtr>
bool | operator!= (const RW_pointer< D, DPtr > &lhs, std::nullptr_t)
template<class D, class DPtr>
bool | operator!= (std::nullptr_t, const RW_pointer< D, DPtr > &rhs)

## Detailed Description

template<class D, class DTraits = rw_pointer::Shared<D>>
struct zypp::RW_pointer< D, DTraits >

Wrapper for `const` correct access via Smart pointer types.

zypp::RW_pointer<D,DTraits> stores a Smart pointer types of type `DTraits::PtrType`, which must be convertible into a D *. Pointer style access (via `->` and `*`) offers a const D * in const a context, otherwise a D *. Thus RW_ means read/write, as you get a different type, dependent on whether you're allowed to read or write.

Forwarding access from an interface to an implemantation class, an RW_pointer prevents const interface methods from accidentally calling nonconst implementation methods.

The second template argument defaults to DTraits = rw_pointer::Shared<D> thus wraping a shared_ptr<D>. To wrap an intrusive_ptr<D> use rw_pointer::Intrusive<D>.

See also
  zypp::RWCOW_pointer for 'copy on write' functionality.

#include "zypp/base/PtrTypes.h"
class Foo
{
...
private:
// Implementation class
struct Impl;
// Pointer to implementation; actually a shared_ptr<Impl>
RW_pointer<Impl> _pimpl;
void baa() { _pimpl->... } // is Impl *
void baa() const { _pimpl->... } // is Impl const *
};
Impl
zypp::RW_pointer::RW_pointer
RW_pointer()
Definition PtrTypes.h:297
PtrTypes.h

Definition at line 292 of file PtrTypes.h.

## Member Typedef Documentation

## ◆ PtrType

template<class D, class DTraits = rw_pointer::Shared<D>>

using zypp::RW_pointer< D, DTraits >::PtrType = typename DTraits::PtrType

Definition at line 294 of file PtrTypes.h.

## ◆ constPtrType

template<class D, class DTraits = rw_pointer::Shared<D>>

using zypp::RW_pointer< D, DTraits >::constPtrType = typename DTraits::constPtrType

Definition at line 295 of file PtrTypes.h.

## Constructor & Destructor Documentation

## ◆ RW_pointer() [1/6]

template<class D, class DTraits = rw_pointer::Shared<D>>

zypp::RW_pointer< D, DTraits >::RW_pointer | ( |  | ) |
| inline

Definition at line 297 of file PtrTypes.h.

## ◆ RW_pointer() [2/6]

template<class D, class DTraits = rw_pointer::Shared<D>>

zypp::RW_pointer< D, DTraits >::RW_pointer | ( | const RW_pointer< D, DTraits > & |  | ) |
| default

## ◆ RW_pointer() [3/6]

template<class D, class DTraits = rw_pointer::Shared<D>>

zypp::RW_pointer< D, DTraits >::RW_pointer | ( | RW_pointer< D, DTraits > && |  | ) |
| default

## ◆ RW_pointer() [4/6]

template<class D, class DTraits = rw_pointer::Shared<D>>

zypp::RW_pointer< D, DTraits >::RW_pointer | ( | std::nullptr_t |  | ) |
| inline

Definition at line 304 of file PtrTypes.h.

## ◆ RW_pointer() [5/6]

template<class D, class DTraits = rw_pointer::Shared<D>>

zypp::RW_pointer< D, DTraits >::RW_pointer | ( | typename PtrType::element_type * | dptr | ) |
| inline explicit

Definition at line 307 of file PtrTypes.h.

## ◆ RW_pointer() [6/6]

template<class D, class DTraits = rw_pointer::Shared<D>>

zypp::RW_pointer< D, DTraits >::RW_pointer | ( | PtrType | dptr | ) |
| inline explicit

Definition at line 312 of file PtrTypes.h.

## Member Function Documentation

## ◆ operator=() [1/3]

template<class D, class DTraits = rw_pointer::Shared<D>>

RW_pointer & zypp::RW_pointer< D, DTraits >::operator= | ( | const RW_pointer< D, DTraits > & |  | ) |
| default

## ◆ operator=() [2/3]

template<class D, class DTraits = rw_pointer::Shared<D>>

RW_pointer & zypp::RW_pointer< D, DTraits >::operator= | ( | RW_pointer< D, DTraits > && |  | ) |
| default

## ◆ operator=() [3/3]

template<class D, class DTraits = rw_pointer::Shared<D>>

RW_pointer & zypp::RW_pointer< D, DTraits >::operator= | ( | std::nullptr_t |  | ) |
| inline

Definition at line 316 of file PtrTypes.h.

## ◆ reset() [1/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

void zypp::RW_pointer< D, DTraits >::reset | ( |  | ) |
| inline

Definition at line 319 of file PtrTypes.h.

## ◆ reset() [2/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

void zypp::RW_pointer< D, DTraits >::reset | ( | typename PtrType::element_type * | dptr | ) |
| inline

Definition at line 322 of file PtrTypes.h.

## ◆ swap() [1/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

void zypp::RW_pointer< D, DTraits >::swap | ( | RW_pointer< D, DTraits > & | rhs | ) |
| inline noexcept

Definition at line 325 of file PtrTypes.h.

## ◆ swap() [2/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

void zypp::RW_pointer< D, DTraits >::swap | ( | PtrType & | rhs | ) |
| inline noexcept

Definition at line 328 of file PtrTypes.h.

## ◆ operator bool()

template<class D, class DTraits = rw_pointer::Shared<D>>

zypp::RW_pointer< D, DTraits >::operator bool | ( |  | ) | const
| inline explicit

Definition at line 331 of file PtrTypes.h.

## ◆ operator*() [1/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

const D & zypp::RW_pointer< D, DTraits >::operator* | ( |  | ) | const
| inline

Definition at line 334 of file PtrTypes.h.

## ◆ operator->() [1/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

const D * zypp::RW_pointer< D, DTraits >::operator-> | ( |  | ) | const
| inline

Definition at line 337 of file PtrTypes.h.

## ◆ get() [1/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

const D * zypp::RW_pointer< D, DTraits >::get | ( |  | ) | const
| inline

Definition at line 340 of file PtrTypes.h.

## ◆ operator*() [2/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

D & zypp::RW_pointer< D, DTraits >::operator* | ( |  | ) |
| inline

Definition at line 343 of file PtrTypes.h.

## ◆ operator->() [2/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

D * zypp::RW_pointer< D, DTraits >::operator-> | ( |  | ) |
| inline

Definition at line 346 of file PtrTypes.h.

## ◆ get() [2/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

D * zypp::RW_pointer< D, DTraits >::get | ( |  | ) |
| inline

Definition at line 349 of file PtrTypes.h.

## ◆ unique()

template<class D, class DTraits = rw_pointer::Shared<D>>

bool zypp::RW_pointer< D, DTraits >::unique | ( |  | ) | const
| inline

Definition at line 353 of file PtrTypes.h.

## ◆ use_count()

template<class D, class DTraits = rw_pointer::Shared<D>>

long zypp::RW_pointer< D, DTraits >::use_count | ( |  | ) | const
| inline

Definition at line 356 of file PtrTypes.h.

## ◆ getPtr() [1/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

constPtrType zypp::RW_pointer< D, DTraits >::getPtr | ( |  | ) | const
| inline

Definition at line 359 of file PtrTypes.h.

## ◆ getPtr() [2/2]

template<class D, class DTraits = rw_pointer::Shared<D>>

PtrType zypp::RW_pointer< D, DTraits >::getPtr | ( |  | ) |
| inline

Definition at line 362 of file PtrTypes.h.

## ◆ cgetPtr()

template<class D, class DTraits = rw_pointer::Shared<D>>

constPtrType zypp::RW_pointer< D, DTraits >::cgetPtr | ( |  | ) |
| inline

Definition at line 365 of file PtrTypes.h.

## Friends And Related Symbol Documentation

## ◆ operator<<()

template<class D, class DPtr>

std::ostream & operator<< | ( | std::ostream & | str,
|  | const RW_pointer< D, DPtr > & | obj )
| related

Stream output.

Print the `D` object the RW_pointer refers, or `"NULL"` if the pointer is `NULL`.

Definition at line 379 of file PtrTypes.h.

## ◆ operator==() [1/7]

template<class D, class DPtr>

bool operator== | ( | const RW_pointer< D, DPtr > & | lhs,
|  | const RW_pointer< D, DPtr > & | rhs )
| related

Definition at line 388 of file PtrTypes.h.

## ◆ operator==() [2/7]

template<class D, class DPtr>

bool operator== | ( | const RW_pointer< D, DPtr > & | lhs,
|  | const typename DPtr::PtrType & | rhs )
| related

Definition at line 392 of file PtrTypes.h.

## ◆ operator==() [3/7]

template<class D, class DPtr>

bool operator== | ( | const typename DPtr::PtrType & | lhs,
|  | const RW_pointer< D, DPtr > & | rhs )
| related

Definition at line 396 of file PtrTypes.h.

## ◆ operator==() [4/7]

template<class D, class DPtr>

bool operator== | ( | const RW_pointer< D, DPtr > & | lhs,
|  | const typename DPtr::constPtrType & | rhs )
| related

Definition at line 400 of file PtrTypes.h.

## ◆ operator==() [5/7]

template<class D, class DPtr>

bool operator== | ( | const typename DPtr::constPtrType & | lhs,
|  | const RW_pointer< D, DPtr > & | rhs )
| related

Definition at line 404 of file PtrTypes.h.

## ◆ operator==() [6/7]

template<class D, class DPtr>

bool operator== | ( | const RW_pointer< D, DPtr > & | lhs,
|  | std::nullptr_t | )
| related

Definition at line 408 of file PtrTypes.h.

## ◆ operator==() [7/7]

template<class D, class DPtr>

bool operator== | ( | std::nullptr_t | ,
|  | const RW_pointer< D, DPtr > & | rhs )
| related

Definition at line 412 of file PtrTypes.h.

## ◆ operator!=() [1/7]

template<class D, class DPtr>

bool operator!= | ( | const RW_pointer< D, DPtr > & | lhs,
|  | const RW_pointer< D, DPtr > & | rhs )
| related

Definition at line 418 of file PtrTypes.h.

## ◆ operator!=() [2/7]

template<class D, class DPtr>

bool operator!= | ( | const RW_pointer< D, DPtr > & | lhs,
|  | const typename DPtr::PtrType & | rhs )
| related

Definition at line 422 of file PtrTypes.h.

## ◆ operator!=() [3/7]

template<class D, class DPtr>

bool operator!= | ( | const typename DPtr::PtrType & | lhs,
|  | const RW_pointer< D, DPtr > & | rhs )
| related

Definition at line 426 of file PtrTypes.h.

## ◆ operator!=() [4/7]

template<class D, class DPtr>

bool operator!= | ( | const RW_pointer< D, DPtr > & | lhs,
|  | const typename DPtr::constPtrType & | rhs )
| related

Definition at line 430 of file PtrTypes.h.

## ◆ operator!=() [5/7]

template<class D, class DPtr>

bool operator!= | ( | const typename DPtr::constPtrType & | lhs,
|  | const RW_pointer< D, DPtr > & | rhs )
| related

Definition at line 434 of file PtrTypes.h.

## ◆ operator!=() [6/7]

template<class D, class DPtr>

bool operator!= | ( | const RW_pointer< D, DPtr > & | lhs,
|  | std::nullptr_t | )
| related

Definition at line 438 of file PtrTypes.h.

## ◆ operator!=() [7/7]

template<class D, class DPtr>

bool operator!= | ( | std::nullptr_t | ,
|  | const RW_pointer< D, DPtr > & | rhs )
| related

Definition at line 442 of file PtrTypes.h.

## Member Data Documentation

## ◆ _dptr

template<class D, class DTraits = rw_pointer::Shared<D>>

PtrType zypp::RW_pointer< D, DTraits >::_dptr
| private

Definition at line 369 of file PtrTypes.h.

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

- zypp-core/base/PtrTypes.h