For anyone stumbling upon this topic, the solution is to use .index, e.g. :
auto boolean_selector = (A == B);
auto C = D.index({boolean_selector});

and for a two-dimensional array where one wants to select along the second dimension of D:
auto boolean_selector = (A == B).squeeze();
auto C = D.index({Slice(), boolean_selector});

with D of size [m x n] and A, B of size [n x 1].