P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::BitRange::MinToMax Struct Reference

#include <bitrange.h>

Detailed Description

A helper type used to construct a range that starts at the minimum index that is safely representable without overflow and ends at the maximum index that is safely representable without overflow. Only meant to be used when constructing a HalfOpenRange or ClosedRange.

MinToMax ranges are useful as an identity when intersecting ranges. If you have a loop where you intersect ranges over and over, you may find MinToMax useful. Note that you're less likely to run into overflow issues with ZeroToMax ranges, so if you're dealing entirely with non-negative numbers, you're probably better off using ZeroToMax.

See also
ZeroToMax for more discussion about what "safely representable" means.

Unlike ZeroToMax, it is not safe to change the endianness of MinToMax; doing so will inevitably result in integer overflow.