I've been using both C++11 and Python lately. While the new C++11 features add a lot of value, I still find it frustratingly verbose for some things. For example, finding an element in a collection:
std::string type = "foo";
auto it = std::find_if(
channel_widgets.begin(),
channel_widgets.end(),
[type](const std::shared_ptr<Widget> &w){
return (w->getType() == type);
}
);
if (it == channel_widgets.end()) {
std::cerr << "widget not found" << std::endl;
} else {
std::shared_ptr<Widget> target_widget = *it;
std::cout << "widget found." << std::endl;
}
versus (for example): type = "foo"
matches = [x for x in widgets if x.get_type() == type];
if matches:
target_widget = matches[0]
print "widget found:",target_widget
else:
print "widget not found"
I may be missing out on some C++11 feature for doing this better. (Or even some Python feature for doing this better!)