Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yes, auto will save you:

    std::vector<bool> features(const Widget& w);
    
    ...

    auto highPriority = features(w)[5];
    processWidget(w, highPriority);  //whoops, undefined behavior
This is from Scott Meyers' new Effective Modern C++, in the chapter about why you should use 'auto'. Even the new 'safe' and 'convenient' features are loaded footguns.


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

Search: