std::unique_ptr::get

pointer get() const; (since C++11) Returns a pointer to the managed object or nullptr if no object is owned. Parameters (none). Return value Pointer to the managed object or nullptr if no object is owned. Exceptions noexcept specification: noexcept Example #include <iostream> #include <string> #include <memory> int main() { std::unique_ptr<std::string> s_p(new std::string("Hello, world!")); std::string *s = s_p.get(); std::cout <&

std::unique_ptr

Defined in header <memory> template< class T, class Deleter = std::default_delete<T> > class unique_ptr; (1) (since C++11) template < class T, class Deleter > class unique_ptr<T[], Deleter>; (2) (since C++11) std::unique_ptr is a smart pointer that retains sole ownership of an object through a pointer and destroys that object when the unique_ptr goes out of scope. No two unique_ptr instances can manage the same object. The objec

std::unique_lock::unlock

void unlock(); (since C++11) Unlocks the associated mutex and releases ownership. std::system_error is thrown if there is no associated mutex or if the mutex is not locked. Parameters (none). Return value (none). Exceptions Any exceptions thrown by mutex()->unlock() If there is no associated mutex or the mutex is not locked, std::system_error with an error code of std::errc::operation_not_permitted Example See also lock locks the associated mutex (public memb

std::unique_lock::unique_lock

unique_lock(); (1) (since C++11) unique_lock( unique_lock&& other ); (2) (since C++11) explicit unique_lock( mutex_type& m ); (3) (since C++11) unique_lock( mutex_type& m, std::defer_lock_t t ); (4) (since C++11) unique_lock( mutex_type& m, std::try_to_lock_t t ); (5) (since C++11) unique_lock( mutex_type& m, std::adopt_lock_t t ); (6) (since C++11) template< class Rep, class Period > unique_lock( mutex_type& m,

std::unique_lock::try_lock_until

template< class Clock, class Duration > bool try_lock_until( const std::chrono::time_point<Clock,Duration>& timeout_time ); (since C++11) Tries to lock the associated mutex. Blocks until specified timeout_time has been reached or the lock is acquired, whichever comes first. On successful lock acquisition returns true, otherwise returns false. May block for longer than until timeout_time has been reached. Effectively calls mutex()->try_lock_until(timeout_time). std::sy

std::unique_lock::try_lock_for

template< class Rep, class Period > bool try_lock_for( const std::chrono::duration<Rep,Period>& timeout_duration ); (since C++11) Tries to lock the associated mutex. Blocks until specified timeout_duration has elapsed or the lock is acquired, whichever comes first. On successful lock acquisition returns true, otherwise returns false. Effectively calls mutex()->try_lock_for(timeout_duration). A steady clock is used to measure the duration. This function may block for l

std::unique_lock::try_lock

bool try_lock(); (since C++11) Tries to lock the associated mutex without blocking. Effectively calls mutex()->try_lock(). std::system_error is thrown if there is no associated mutex or if the mutex is already locked by this std::unique_lock. Parameters (none). Return value true if the ownership of the mutex has been acquired successfully, false otherwise. Exceptions Any exceptions thrown by mutex()->try_lock() (Mutex types do not throw in try_lock, but a custom Lockable

std::unique_lock::swap

void swap( unique_lock& other ); (since C++11) Exchanges the internal states of the lock objects. Parameters other - the lock to swap the state with Return value (none). Exceptions noexcept specification: noexcept Example See also std::swap(std::unique_lock) (C++11) specialization of std::swap for unique_lock (function template)

std::unique_lock::release

mutex_type* release(); (since C++11) Breaks the association of the associated mutex, if any, and *this. No locks are unlocked. If the *this held ownership of the associated mutex prior to the call, the caller is now responsible to unlock the mutex. Parameters (none). Return value Pointer to the associated mutex or NULL if there was no associated mutex. Exceptions noexcept specification: noexcept Example See also unlock unlocks the associated mutex (public member fun

std::unique_lock::owns_lock

bool owns_lock() const; (since C++11) Checks whether *this owns a locked mutex or not. Parameters (none). Return value true if *this has an associated mutex and has acquired ownership of it, false otherwise. Exceptions noexcept specification: noexcept See also operator bool tests whether the lock owns its associated mutex (public member function)