Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::ManuallyDrop< T > Class Template Reference

#include <manually-drop.hh>

Public Member Functions

 ManuallyDrop (T &&t)
template<typename... Arg>
 ManuallyDrop (std::in_place_t, Arg &&... args)
 ManuallyDrop (ManuallyDrop< T > &&other)
T & get ()
T & operator* ()
T * operator-> ()
T && take () &&
void destroy ()

Detailed Description

template<typename T>
class nix::ManuallyDrop< T >

Analogous to Rust's ManuallyDrop structure. Only is destroyed when you call destroy().

Constructor & Destructor Documentation

◆ ManuallyDrop()

template<typename T>
template<typename... Arg>
nix::ManuallyDrop< T >::ManuallyDrop ( std::in_place_t ,
Arg &&... args )
inline

Construct a ManuallyDrop in-place

Member Function Documentation

◆ destroy()

template<typename T>
void nix::ManuallyDrop< T >::destroy ( )
inline

Destroy the value. Safe to call multiple times.

◆ get()

template<typename T>
T & nix::ManuallyDrop< T >::get ( )
inline

Gets a reference to the inner T

◆ take()

template<typename T>
T && nix::ManuallyDrop< T >::take ( ) &&
inline

Takes the value out of this object and gives it to you. Must not already be destroyed.

Example:

ManuallyDrop<std::unique_ptr<int>> md{std::in_place_t{}, new int()};
ManuallyDrop<std::unique_ptr<int>> md2{std::move(md).take()};

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