A Small Set-Algorithm For Enum Values -- Felix Petriconi

Inspired by Sean Parent's recent Tweet I came up with this idea:

A Small Set-Algorithm For Enum Values

by Felix Petriconi

From the article:

Often we have in our own production code statements like this:

auto predicate = [](State state) {
  return state == MyEnumClass::ValueA ||
         state == MyEnumClass::ValueD ||
         state == MyEnumClass::ValueEWithAVeryLongName;
};

A better readable solution with less typing is described there.

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.