J
Jerry
This works fine:
int main()
{
std::map<std::string,std::string> parameters;
parameters["abc"]="def";
std::for_each(parameters.begin(),parameters.end(),
[] (std::map<std::string,std::string>::value_type& pair)
{std::cout << pair.first << "=" << pair.second << " ";});
return 0;
}
But g++ 4.6.0 doesn't like it when I change the type of pair in the
lambda to auto:
int main()
{
std::map<std::string,std::string> parameters;
parameters["abc"]="def";
std::for_each(parameters.begin(),parameters.end(),
[] (auto pair)
{std::cout << pair.first << "=" << pair.second << " ";});
return 0;
}
So, my question is: why can't it be auto?
In general I am most interested in why the committee chooses to
include things or not and I figure there must be a reason this isn't
allowed. Or is it allowed and my compiler is just too old?
Thanks,
Jerry
int main()
{
std::map<std::string,std::string> parameters;
parameters["abc"]="def";
std::for_each(parameters.begin(),parameters.end(),
[] (std::map<std::string,std::string>::value_type& pair)
{std::cout << pair.first << "=" << pair.second << " ";});
return 0;
}
But g++ 4.6.0 doesn't like it when I change the type of pair in the
lambda to auto:
int main()
{
std::map<std::string,std::string> parameters;
parameters["abc"]="def";
std::for_each(parameters.begin(),parameters.end(),
[] (auto pair)
{std::cout << pair.first << "=" << pair.second << " ";});
return 0;
}
So, my question is: why can't it be auto?
In general I am most interested in why the committee chooses to
include things or not and I figure there must be a reason this isn't
allowed. Or is it allowed and my compiler is just too old?
Thanks,
Jerry