On Monday, 3 September 2012 at 10:42:34 UTC, Andrei Alexandrescu wrote:
I would advocate using, a < x < b, this trivially addresses open/closed
intervals etc.

I disagree with the porting from other languages argument... comparing bool with < > is not a common occurring pattern, and even if there is such code in the wild, many coding standards would force the use of () if using such an expression anyway... so the porting issues would be
minimal.

It's a sensible argument. What about "among"?

Andrei

Since 'among' only is concerned with equality it doesn't suffer from the open/closed interval complication... thus in this case, the simplest solution is the best imho... 'in' sugar would not add much to the readability.

if (a.among("struct", "class", "union")) { ... }

Reply via email to