News for hackers. Stuff that matters.
Re:Const all the things? by flohofwoe on Monday January 24, 2022 @07:30AM (#30056831)
> now you have to add a check for null inside your function

While I generally agree that non-const references make more sense for out-parameters (although I actually prefer return values), don't forget that it's possible for a reference to become "null" too. It's quite unlikely to happen, but if it happens it's much worse to debug than a null pointer.

Oversimplified example:

    const int& bla = *((int*)nullptr);
Re:Const all the things? by mastax on Monday January 24, 2022 @10:42AM (#30059004)
Dereferencing a null pointer is Undefined Behavior.