-
Notifications
You must be signed in to change notification settings - Fork 365
Closed
Description
The following code creates parser errors (line 11 and line 23).
// Win32Project1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
std::vector<std::string> v = { "test1", "test2", "test3" };
for (const std::string &i : v) // access by const reference
std::cout << i.c_str() << ' ';
std::cout << '\n';
for (auto i : v) // access by value, the type of i is int
std::cout << i.c_str() << ' ';
std::cout << '\n';
for (auto&& i : v) // access by reference, the type of i is int&
std::cout << i.c_str() << ' ';
std::cout << '\n';
for (std::string n : {"test1", "test2", "test3"}) // the initializer may be a braced-init-list
std::cout << n.c_str() << ' ';
std::cout << '\n';
return 0;
}