std::vector::capacity

size_type capacity() const; Returns the number of elements that the container has currently allocated space for. Parameters (none). Return value Capacity of the currently allocated storage. Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Constant. See also size returns the number of elements (public member function) reserve reserves storage (public member function)

std::vector::clear

void clear(); Removes all elements from the container. Invalidates any references, pointers, or iterators referring to contained elements. May invalidate any past-the-end iterators. Leaves the capacity() of the vector unchanged. Parameters (none). Return value (none). Exceptions (none) (until C++11) noexcept specification: noexcept (since C++11) Complexity Linear in the size of the container. clear is defined in terms of erase, which has linear complexity. (until C++1

std::vector::back

reference back(); const_reference back() const; Returns reference to the last element in the container. Calling back on an empty container is undefined. Parameters (none). Return value Reference to the last element. Complexity Constant. Notes For a container c, the expression return c.back(); is equivalent to { auto tmp = c.end(); --tmp; return *tmp; } Example The following code uses back to display the last element of a std::vector<char>: #include <vector

std::vector::at

reference at( size_type pos ); const_reference at( size_type pos ) const; Returns a reference to the element at specified location pos, with bounds checking. If pos not within the range of the container, an exception of type std::out_of_range is thrown. Parameters pos - position of the element to return Return value Reference to the requested element. Exceptions std::out_of_range if !(pos < size()). Complexity Constant. See also operator[] acces

std::valarray::valarray

valarray(); (1) explicit valarray( std::size_t count ); (2) valarray( const T& val, std::size_t count ); (3) valarray( const T* vals, std::size_t count ); (4) valarray( const valarray& other ); (5) valarray( valarray&& other ); (6) (since C++11) valarray( const std::slice_array<T>& ); (7) valarray( const std::gslice_array<T>& ); (8) valarray( const std::mask_array<T>& ); (9) valarray( const std:

std::vector

Defined in header <vector> template< class T, class Allocator = std::allocator<T> > class vector; std::vector is a sequence container that encapsulates dynamic size arrays. The elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets on regular pointers to elements. This means that a pointer to an element of a vector may be passed to any function that expects a pointer to an element o

std::va_list

Defined in header <cstdarg> typedef /* unspecified */ va_list; va_list is a complete object type suitable for holding the information needed by the macros va_start, va_copy, va_arg, and va_end. If a va_list instance is created, passed to another function, and used via va_arg in that function, then any subsequent use in the calling function should be preceded by a call to va_end. It is legal to pass a pointer to a va_list object to another function and then use that object a

std::valarray::size

std::size_t size() const; Returns the number of elements in the valarray. Parameters (none). Return value Number of elements in the valarray. Example See also resize changes the size of valarray (public member function)

std::valarray::shift

valarray<T> shift( int count ) const; Returns a new valarray of the same size with elements whose positions are shifted by count elements. The new position of each element is i−count where i is the previous position. The value of shifted in elements is T(). Parameters count - number of positions to shift the elements by Return value The resulting valarray with shifted elements. Notes The function can be implemented with the return type different from std::valarray

std::valarray::sum

T sum() const; Computes the sum of the elements. The function can be used only if operator+= is defined for type T. If the std::valarray is empty, the behavior is undefined. The order in which the elements are processed by this function is unspecified. Parameters (none). Return value The sum of the elements. Example #include <iostream> #include <valarray> int main() { std::valarray<int> a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; std::cout << a.sum(