The Insider News

The Insider News is for breaking IT and Software development news. Post your news, your alerts and
your inside scoops. This is an IT news-only forum - all off-topic, non-news posts will be
removed. If you wish to ask a programming question please post it
here.

Get The Daily Insider direct to your mailbox every day. Subscribe
now!

When we think of the comma character we often think of it as a separator. It separates values in an CSV file, it separates items in lists, it may separate index values in multidimensional arrays (in other languages) and more. But in C++ an obscure way of using them was as an operator. The reason it never made it big as an operator and into the typical programming psyche is that largely it is seen as useless or some kind of "syntactic sugar". So in this article we try to show how it works, why it has a stigma and some possible uses for it that may prove useful at some point in your career going forward.

Kind of misses the best bits sadly. The comma operator can be used to explicitly control order of operation, i.e. prevent the compiler from reordering things that aren't directly related but have a hidden ordering dependency. Using the comma operator this way is the solution to Alexander Andrescu's pure C++ portable mutex implementation problem. I must write this up with a test case at some point, busy, busy, busy

"The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)