When a good deal of compilers support std::optional
, do you think we will need to adjust tutorials that explain when to use pointers as function parameters? E.g. in this article:
As well as in many others, it is suggested to use pointer parameters when the parameter may be [code]nullptr[/tt], or, in other words, when the parameter is optional
Or do you think that the traditional pass-by-pointer technique has benefits over std::optional
? Exclude speed/performance, as we will assume for the sake of this discussion that compilers can optimize both versions to equivalent code.
Note also that this is not only relevant to function parameters, as optional
data is common in other places too - function parameters just seemed most iconic to me.
Personally, I will immediately start using std::optional
- I dislike the ugly pointer syntax with a passion and even the workarounds like making a reference to the dereferenced pointer.
EDIT: It seems that std::optional
won't be making it into C++14 after all. Oh well. I guess we can assume it will make it to C++17 (or whatever year that is expected to be released).