std::unordered_map::at

T& at( const Key& key ); (1) (since C++11) const T& at( const Key& key ) const; (2) (since C++11) Returns a reference to the mapped value of the element with key equivalent to key. If no such element exists, an exception of type std::out_of_range is thrown. Parameters key - the key of the element to find Return value Reference to the mapped value of the requested element. Exceptions std::out_of_range if the container does not have an element with t

std::unordered_map

Defined in header <unordered_map> template< class Key, class T, class Hash = std::hash<Key>, class KeyEqual = std::equal_to<Key>, class Allocator = std::allocator< std::pair<const Key, T> > > class unordered_map; (since C++11) Unordered map is an associative container that contains key-value pairs with unique keys. Search, insertion, and removal of elements have average constant-time complexity. Internally, the elements are

std::unitbuf

Defined in header <ios> std::ios_base& unitbuf( std::ios_base& str ); (1) std::ios_base& nounitbuf( std::ios_base& str ); (2) Enables or disables automatic flushing of the output stream after any output operation. Has no effect on input. 1) enables the unitbuf flag in the stream str as if by calling str.setf(std::ios_base::unitbuf). 2) disables the unitbuf flag in the stream str as if by calling str.unsetf(std::ios_base::unitbuf). This is an I/O manipu

std::unique_ptr::unique_ptr

members of the primary template, unique_ptr<T> constexpr unique_ptr(); constexpr unique_ptr( nullptr_t ); (1) explicit unique_ptr( pointer p ); (2) unique_ptr( pointer p, /* see below */ d1 ); (3) unique_ptr( pointer p, /* see below */ d2 ); (4) unique_ptr( unique_ptr&& u ); (5) template< class U, class E > unique_ptr( unique_ptr<U, E>&& u ); (6) template< class U > unique_ptr( auto_ptr<U>&& u ); (7

std::unique_ptr::swap

void swap(unique_ptr& other); (since C++11) Swaps the managed objects and associated deleters of *this and another unique_ptr object other. Parameters other - another unique_ptr object to swap the managed object and the deleter with Return value (none). Exceptions noexcept specification: noexcept Example #include <iostream> #include <memory> struct Foo { Foo(int _val) : val(_val) { std::cout << "Foo...\n"; } ~Foo() { std::cout <

std::unique_ptr::reset

members of the primary template, unique_ptr<T> void reset( pointer ptr = pointer() ); (1) members of the specialization unique_ptr<T[]> void reset( pointer ptr = pointer() ); (2) (until C++17) (3) template< class U > void reset( U ) = delete; (until C++17) template< class U > void reset( U ); (since C++17) (4) void reset( std::nullptr_t p ); (until C++17) void reset( std::nullptr_t p = nullptr ); (since C++17) Replaces the

std::unique_ptr::release

pointer release(); (since C++11) Releases the ownership of the managed object if any. get() returns nullptr after the call. Parameters (none). Return value Pointer to the managed object or nullptr if there was no managed object, i.e. the value which would be returned by get() before the call. Exceptions noexcept specification: noexcept Example #include <memory> #include <iostream> #include <cassert> struct Foo { Foo() { std::cout << "Foo\n";

std::unique_ptr::operator[]

T& operator[](size_t i) const; (since C++11) operator[] provides access to elements of an array managed by a unique_ptr. The parameter i is required to be a valid array index. Parameters i - the index of the element to be returned Return value Returns the element at index i, i.e. get()[i]. Example #include <iostream> #include <memory> int main() { const int size = 10; std::unique_ptr<int[]> fact(new int[size]); for (int i = 0; i

std::unique_ptr::operator bool

explicit operator bool() const; (since C++11) Checks whether *this owns an object, i.e. whether get() != nullptr. Parameters (none). Return value true if *this owns an object, false otherwise. Exceptions noexcept specification: noexcept Example #include <iostream> #include <memory> int main() { std::unique_ptr<int> ptr(new int(42)); if (ptr) std::cout << "before reset, ptr is: " << *ptr << '\n'; ptr.reset(); if (ptr

std::unique_ptr::get_deleter

Deleter& get_deleter(); (since C++11) const Deleter& get_deleter() const; (since C++11) Returns the deleter object which would be used for destruction of the managed object. Parameters (none). Return value The stored deleter object. Exceptions noexcept specification: noexcept Example #include <iostream> #include <memory> struct Foo { Foo() { std::cout << "Foo...\n"; } ~Foo() { std::cout << "~Foo...\n"; } }; struct D