+ void Union (wide_int x, wide_int y);
+ bool Union (const irange &r);
+ bool Union (const irange &r1, const irange &r2);
+
+ // THIS = THIS ^ [X,Y]. Return TRUE if result is non-empty.
+ bool Intersect (wide_int x, wide_int y, bool readonly = false);
+ // THIS = THIS ^ R. Return TRUE if result is non-empty.
+ // THIS = R1 ^ R2. Return TRUE if result is non-empty.
+ bool Intersect (const irange &r1, const irange &r2, bool readonly =
false);
+ // Return TRUE if THIS ^ R will be non-empty.
+ bool Intersect_p (const irange &r)
+ { return Intersect (r, /*readonly=*/true); }
I would suggest the following changes to Union, Intersect, and Not:
1) Define all three members without the readonly argument and
returning irange& (i.e., *this). The return value can be
used wherever irange& is expected, and the is_empty() member
function can be called on it to obtain the same result. E.g.,
Intersect A with B, storing the result in A:
irange A, B;
if (A.Intersect (B).is_empty ()) { ... }
2) Add non-members like so:
irange range_union (const irange &lhs, const irange &rhs)
{
return irange (lhs).Union (rhs);
}
and find out if the union of A or B is empty without modifying
either argument:
irange A, B;
if (range_union (A, B).is_empty ()) { ... }