Hacker News new | past | comments | ask | show | jobs | submit login

boost::range can makes a bit less verbose:

    std::string type("foo");
    auto range = channel_widgets | filter([type](const std::shared_ptr<Widget> &w) { 
                                              return w->getType() == type;
                                          });
    if (range) {
        std::string target_widget = *range.begin();
        std::cout << "widget found." << std::endl;
    } else {
        std::cerr << "widget not found" << std::endl;
    }



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: