Remix.run Logo
▲ tniemi 7 hours ago

That `(1 ? (item) : (list)->payload)` was a neat trick. It gets optimized away, but the type comparison happens before that.

Still feels a bit like a party trick, but if it works...

▲JdeBP 6 hours ago | parent | next [-]

It's somewhat of a forced trick nowadays, I think.

I actually thought from the title before I read the article that it was going to use _Generic, as in something like _Generic((item),__typeof__((list)->payload):...) .

▲Xirdus 7 hours ago | parent | prev [-]

Expressions that compile but never evaluate are bread and butter in C++ template metaprogramming.