Every iteration of the loop creates a local variable x
and initializes it to the next element of vec
. When the loop iteration ends, x
goes out of scope. A single x
is never modified.
See this link for the precise semantics.
More Related Contents:
- What are Aggregates and PODs and how/why are they special?
- Why C++11 in-class initializer cannot use parentheses?
- C++11 does not deduce type when std::function or lambda functions are involved
- Sorting zipped (locked) containers in C++ using boost or the STL
- When should I really use noexcept?
- What does the single ampersand after the parameter list of a member function declaration mean?
- Why is `std::move` named `std::move`?
- What does the thread_local mean in C++11?
- How to check if a std::thread is still running?
- What is the ‘override’ keyword in C++ used for? [duplicate]
- What exactly is std::atomic?
- When to use std::forward to forward arguments?
- check variadic templates parameters for uniqueness
- Using member variable in lambda capture list inside a member function
- Can an enum class be converted to the underlying type?
- What’s a use case for overloading member functions on reference qualifiers?
- The reason of using `std::greater` for creating min heap via `priority_queue`
- istream behavior change in C++ upon failure
- std::shared_ptr initialization: make_shared() vs shared_ptr(new Foo) [duplicate]
- Initializer list not working with vector in Visual Studio 2012? [duplicate]
- What does the void() in decltype(void()) mean exactly?
- Why does std::istringstream appear to resolve differently to std::ifstream in the ternary (?:) operator?
- Can the point-of-instantiation be delayed until the end of the translation unit?
- Is there a range class in C++11 for use with range based for loops?
- std::auto_ptr to std::unique_ptr
- How to update GCC in MinGW on Windows?
- Understanding rvalue references
- Why can’t std::function bind to C-style variadic functions?
- Why the sequence-operation algorithms predicates are passed by copy?
- Range based for loop in function which passes an array as value [duplicate]