There’s a function std::reverse
in the algorithm
header for this purpose.
#include <vector> #include <algorithm> int main() { std::vector<int> a; std::reverse(a.begin(), a.end()); return 0; }
Related Posts:
- What is the easiest way to initialize a std::vector with hardcoded elements?
- How to find out if an item is present in a std::vector?
- How do I erase an element from std::vector<> by index?
- Is it more efficient to copy a vector by reserving and copying, or by creating and swapping? [duplicate]
- What’s the most efficient way to erase duplicates and sort a vector?
- Best way to extract a subvector from a vector?
- Appending a vector to a vector
- C++ Erase vector element by value rather than by position?
- Why can’t I make a vector of references?
- Displaying contents of a vector container in C++
- How to implement 2D vector array?
- Why is “using namespace std;” considered bad practice?
- Vector of Vectors to create matrix
- How do I print out the contents of a vector?
- check if a std::vector contains a certain object?
- How to navigate through a vector using iterators? (C++)
- C++ for each, pulling from vector elements
- Replace part of a string with another string
- Debug assertion failed. C++ vector subscript out of range
- A proper way to create a matrix in c++
- No matching member function for call to ‘push_back’ error
- Pass a vector by reference C++
- Why there is no pop_front method in C++ std::vector?
- Initializing a two dimensional std::vector
- C++ – No matching member function for call to ‘push_back’
- Debug assertion failed. C++ vector subscript out of range
- Vector is not a Template?
- Displaying a vector of strings in C++
- ‘vector’ in namespace ‘std’ does not have a template type
- Issue with std::stol – ‘std::invalid_argument’ what(): stol
- Is there a tab equivalent of std::endl within the standard library?
- push_back vs emplace_back
- Why am I getting string does not name a type Error?
- C++ error: Undefined symbols for architecture x86_64
- Vector of structs initialization
- Converting a vector
to string - vector
::size_type in C++ - Parsing a comma-delimited std::string
- How to ensure that a std::map is ordered?
- Why use a new call with a C++ ‘vector’?
- Why doesn’t std::vector::push_front() exist?
- C++ delete vector, objects, free memory
- How to iterate over a vector?
- How to access the contents of a vector from a pointer to the vector in C++?
- printf with std::string?
- Insert object at index of vector c++
- How to convert vector to array
- push_back vs emplace_back
- No operator << matches these operands
- Initialize empty vector in structure – c++
- Append an int to a std::string
- splitting a string into an array in C++ without using vector
- Remove spaces from std::string in C++
- What is the difference between const_iterator and non-const iterator in the C++ STL?
- Remove spaces from std::string in C++
- How to check that an element is in a std::set?
- How to sum up elements of a C++ vector?
- Implementation of Vector in C++
- Determine if map contains a value for a key?
- cc1plus: error: unrecognized command line option “-std=c++11” with g++
- How to initialize a vector of pointers
- Correct way to work with vector of arrays
- C++ error: double free or corruption (fasttop)
- How to get current time in milliseconds?
- Use the auto keyword in C++ STL
- error C2106: ‘=’ : left operand must be l-value
- I get this error: “glibc detected”
- std::string length() and size() member functions
- How to create a vector of class objects in C++?
- “vector” was not declared in this scope
- sorting in std::map where key is a std::string
- How to do std::string indexof in C++ that returns index of matching string?
- Vector declaration “expected parameter declarator”
- Why is this vector iterator not incrementable?
- error C2065: ‘cout’ : undeclared identifier
- C++ equivalent of StringBuffer/StringBuilder?
- What is the size of sizeof(vector)? C++
- List iterator not dereferencable?
- c++ vector bubble sort
- clearing a vector of pointers [duplicate]
- I’m getting the error “stoi is not a member of std” in myprogramminglab [duplicate]
- “Cannot allocate an object of abstract type” error
- Expected initializer before namespace
- Separating class code into a header and cpp file
- Deep copy vs Shallow Copy
- C# equivalent of C++ vector, with contiguous memory?
- Pointer to incomplete class type is not allowed
- Checking cin input stream produces an integer
- What is the best open XML parser for C++?
- *** No rule to make target ‘class.cpp’, needed by `build/….x86/class.o` Stop. error in Ubuntu
- What’s the difference between opening a file with ios::binary or ios::out or both?
- error: called object type ‘int’ is not a function or function pointer
- Hash function for a string
- Don’t understand static boolean behavior
- How to write std::string to file?
- Member declaration not found
- Incomplete type is not allowed: stringstream
- Evaluate a string with a switch in C++ [duplicate]
- C++ JSON Serialization
- stack around the variable…was corrupted