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

> you still need to initialize the optional itself.

Isn't initalising an optional basically a trivial operation? The default constructor is fundamentally the equivalent of setting a boolean flag to 0.



Be careful that 'trivial' is a term if art in the context of C++ initialization. Having to do work is different than not having to do it. Constructting a vector of N optionals is O(N) as opposed of a vector of a truly trivially constructible type, which is O(1) (although I'm not 100% sure if the standard guarantees it or it is just a QoI).




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

Search: