balancedParens

fnbool balancedParens(Range, E)(Range r, E lPar, E rPar, size_t maxNestingLevel = size_t.max) if (isInputRange!(Range) && is(typeof(r.front == lPar)))

Checks whether r has "balanced parentheses", i.e. all instances of lPar are closed by corresponding instances of rPar. The parameter maxNestingLevel controls the nesting level allowed. The most common uses are the default or 0. In the latter case, no nesting is allowed.

Parameters

rThe range to check.
lParThe element corresponding with a left (opening) parenthesis.
rParThe element corresponding with a right (closing) parenthesis.
maxNestingLevelThe maximum allowed nesting level.

Returns

true if the given range has balanced parenthesis within the given maximum

nesting level; false otherwise.