std::unordered_map::begin

iterator begin(); (since C++11) const_iterator begin() const; (since C++11) const_iterator cbegin() const; (since C++11) Returns an iterator to the first element of the container. If the container is empty, the returned iterator will be equal to end(). Parameters (none). Return value Iterator to the first element. Exceptions noexcept specification: noexcept Complexity Constant. Example See also end cend returns an iterator to the end (public member

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::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::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::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::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::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::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::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