qxLib
Classes | Typedefs | Functions
unique_ref.h File Reference
#include <qx/smart_ptr/smart_ptr_ref_adapter.h>
#include <qx/smart_ptr/unique_ref.inl>

Go to the source code of this file.

Classes

class  qx::details::smart_ptr_ref_adapter< std::unique_ptr, T, args_t... >
 

Typedefs

template<class T , class deleter_t = std::default_delete<T>>
using qx::unique_ref = details::smart_ptr_ref_adapter< std::unique_ptr, T, deleter_t >
 A version of std::unique_ptr that cannot have an invalid value (nullptr) (compile time guaranteed). More...
 

Functions

template<class T , class... constructor_args_t>
unique_ref< T > qx::make_unique_ref (constructor_args_t &&... args)
 Make a unique ref (same as std::make_unique but for qx::unique_ref) More...
 
template<class T , class deleter_t , class... constructor_args_t>
unique_ref< T, deleter_t > qx::make_unique_ref_with_deleter (deleter_t deleter, constructor_args_t &&... args)
 Make a unique ref with a custom deleter. More...
 

Detailed Description

Author
Khrapov
Date
25.05.2025

Definition in file unique_ref.h.

Typedef Documentation

◆ unique_ref

template<class T , class deleter_t = std::default_delete<T>>
using qx::unique_ref = typedef details::smart_ptr_ref_adapter<std::unique_ptr, T, deleter_t>

A version of std::unique_ptr that cannot have an invalid value (nullptr) (compile time guaranteed).

Can only be constructed with make_unique_ref or make_unique_ref_with_deleter. Cannot be constructed from / assigned from / reset from a unique_ptr.

Template Parameters
T- type to store
deleter_t- optional custom deleter

Definition at line 24 of file unique_ref.h.

Function Documentation

◆ make_unique_ref()

template<class T , class... constructor_args_t>
unique_ref< T > qx::make_unique_ref ( constructor_args_t &&...  args)

Make a unique ref (same as std::make_unique but for qx::unique_ref)

Template Parameters
T- type to store
constructor_args_t- T constructor types
Parameters
args- T constructor values
Return values
-made unique_ref

Definition at line 14 of file unique_ref.inl.

◆ make_unique_ref_with_deleter()

template<class T , class deleter_t , class... constructor_args_t>
unique_ref< T, deleter_t > qx::make_unique_ref_with_deleter ( deleter_t  deleter,
constructor_args_t &&...  args 
)

Make a unique ref with a custom deleter.

Template Parameters
T- type to store
deleter_t- custom constructor type
constructor_args_t- T constructor types
Parameters
deleter- custom constructor
args- T constructor values
Return values
-made unique_ref

Definition at line 22 of file unique_ref.inl.