For example I have the following string,
if (str[i] == \'(\' ||
str[i] == \')\' ||
str[i] == \'+\' ||
str[i] == \'-\' ||
str[i] == \'/\' ||
s
Maybe not "more concise", but I think this style is succinct and expressive at the point of the test.
Of course is_arithmetic_punctuation
needn't be a lambda if you're going to use it more than once. It could be a function or a function object.
auto is_arithmetic_punctuation = [](char c)
{
switch(c)
{
case '(':
case ')':
case '+':
case '-':
case '/':
case '*':
return true;
default:
return false;
}
};
if (is_arithmetic_punctuation(str[i]))
{
// ...
}