It is my understanding that std::find_if() below
returns an iterator to the first element in the range of arg
for which the third argument (lamda function) returns true. Is that correct?
Could somebody explain why there isn't an iterator defined like this std::pair<std::string, std::type_index>::iterator = std::find_if(...)
?
Where is the iterator returned by std::findif()
stored and how can you call ->second
on its own and not on an iterator?
and why is there a != args_.end()
after the closing brace of std::find_if
?
std::type_index argType(const std::string& name) const
{
return std::find_if(args_.begin(), args_.end(),
[&name](std::pair<std::string, std::type_index> arg)->bool
{
return arg.first == name;
}
)->second;
}
Aucun commentaire:
Enregistrer un commentaire