Get the latest tech news

For Better or for Worse, the Overload (2024)


You know what’s stuck on my mind? Ever since writing my last post, it’s been the word “better.” It came up when we were talking about overload resolution and implicit conversion sequences. I explained a necessary special case of it—something about how adding const in a reference-binding is preferred against—and then strategically shut up about the rest.

This is a cute way of extending the lifetime of a temporary: it happens in cases like the array-to-pointer conversion mentioned earlier, binding a reference to a prvalue, and so on. Reveal answerThis one is ill-formed because disambiguation never happens by top-level cv-qualifiers for a non-reference type—any call would be ambiguous, so this “overload” counts as re-definition. Sure, you can avoid this nonsense by writing sane overloads and not nesting pointers too deeply, but it’s a little terrifying standing back and looking at this grand, winding Rube Goldberg machine that exists just to support ad hoc polymorphism—i.e, name sharing.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Overload

Overload