Comment

Comment by bregma

We use this question in technical interviews (we hire compiler developers for whom this sort of esoteric knowledge is daily bread).

It illustrates one of the incompatibilities between the C programming language and the C++ programming language. In C, the result of the comma operator is always an rvalue so it's not a valid assignment. In C++, it's an rvalue reference , which can be effectively thought of as an lvalue (without going through the convoluted value category reasoning specified by the standard which will leave anyone stymied), so it's a valid assignment.

The problems come when people think "C++ is just a superset of C" and don't know what they're talking about.

parent bregma 2 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton