logoalt Hacker News

dwattttt • today at 9:02 AM • 0 replies • view on HN

One of the first production C++ codebases I worked on had helpers:

  Type& GetReference(Type*);
(Type is a placeholder, it was not templated). It worked exactly how you'd fear it would, and as a result we had to chase down null dereferences of our "can't be null" references all over the codebase.

EDIT: by "exactly how you fear it would", it just did a dereference and return. It didn't check for null, didn't throw, and couldn't otherwise signal a failure.