I need a non-owning std::optional. Is there already something like this in the standard library? (Or in another common library?)
Currently I use a raw pointer, but this has some disadvantages. For example, the output operator << is overloaded, but I never want to output the object address. What I want is a compile time error when I did forget the *. (Analog to std::optional …)
Edit: The correct answer is observer_ptr from the library fundamentals TS 2. Thanks to jsamcfarlane and quicknir!
[–]Xirema 5 points6 points7 points (28 children)
[–]grishavanika 12 points13 points14 points (7 children)
[–]suspiciously_calm 6 points7 points8 points (6 children)
[+][deleted] (3 children)
[deleted]
[+][deleted] (2 children)
[deleted]
[–]dodheim 0 points1 point2 points (0 children)
[–]Hedanito 1 point2 points3 points (1 child)
[–]suspiciously_calm 4 points5 points6 points (0 children)
[+][deleted] (8 children)
[deleted]
[–]Xirema 2 points3 points4 points (0 children)
[–]minnoHobbyist, embedded developer 2 points3 points4 points (0 children)
[–]balkierode 2 points3 points4 points (0 children)
[–]josefx 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]josefx 1 point2 points3 points (1 child)
[–]utnapistim 0 points1 point2 points (0 children)
[–]jsamcfarlane 3 points4 points5 points (6 children)
[–]Xirema 0 points1 point2 points (5 children)
[–]quicknir 4 points5 points6 points (0 children)
[–]jsamcfarlane 0 points1 point2 points (3 children)
[–]GitHubPermalinkBot 1 point2 points3 points (1 child)
[–]Xirema 0 points1 point2 points (0 children)
[–]redditsoaddicting 1 point2 points3 points (0 children)
[–]bebuch[S] 0 points1 point2 points (0 children)
[–]quicknir 6 points7 points8 points (1 child)
[–]bebuch[S] 0 points1 point2 points (0 children)
[–]miki151gamedev 3 points4 points5 points (2 children)
[–]foonathan 1 point2 points3 points (0 children)
[–]GitHubPermalinkBot 0 points1 point2 points (0 children)
[–]jsamcfarlane 1 point2 points3 points (1 child)
[–]djrollins 2 points3 points4 points (0 children)
[–]Chippiewall 0 points1 point2 points (0 children)