Add advice about Optional function arguments

This comes from here:
https://codereview.webrtc.org/2585293002/diff/1/webrtc/modules/audio_coding/audio_network_adaptor/fec_controller.h#newcode91

BUG=none
NOTRY=true

Review-Url: https://codereview.webrtc.org/2624573004
Cr-Commit-Position: refs/heads/master@{#15980}
This commit is contained in:
kwiberg 2017-01-10 02:11:17 -08:00 committed by Commit bot
parent ebfbc8ebfd
commit b3f7dbc7a5

View File

@ -77,6 +77,12 @@ inline T* FunctionThatDoesNothing(T* x) { return x; }
// might make sense, but any larger parse job is probably going to need to
// tell the caller what the problem was, not just that there was one.
//
// - As a non-mutable function argument. When you want to pass a value of a
// type T that can fail to be there, const T* is almost always both fastest
// and cleanest. (If you're *sure* that the the caller will always already
// have an Optional<T>, const Optional<T>& is slightly faster than const T*,
// but this is a micro-optimization. In general, stick to const T*.)
//
// TODO(kwiberg): Get rid of this class when the standard library has
// std::optional (and we're allowed to use it).
template <typename T>