Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • 1
    Yup, boost::optional. Is there a document showing its acceptance into C++17? Edit: I guess this'll do: en.cppreference.com/w/cpp/utility/optional Commented Apr 15, 2016 at 10:26
  • 1
    @underscore_d At this the N paper appears to be N4270, although the actual linked version of the paper seems rough (or "drafty" shall we say?) Commented Apr 15, 2016 at 10:36
  • Cool, thanks for the info! I hadn't heard about this being incorporated until now... or if I did hear, then I immediately forgot. Commented Apr 15, 2016 at 10:46
  • 3
    Your suggested code is wrong; std::make_unique requires a template argument specifying the object type to create, it forwards the function arguments to that object's constructor, and it never returns an empty pointer. Creating an empty pointer is just std::unique_ptr<myClass>{}; creating non-empty is std::make_unique<myClass>(myClassCtorArgs...) Commented Nov 15, 2017 at 16:37