Template Struct pn532::with_inf

Struct Documentation

template<class Integral>
struct with_inf

Wrapper around an integral type that can take pn532::infty and assign to the underlying integer type its maximum value.

In the PN532, sometimes the natural maximum (std::numeric_limits<Integral>::max()) of an integral type is used to signal infinity, e.g. repeat an operation indefinitely. This template explicitly marks this property by adding some syntactic sugar to the type. This type behaves exactly like the underlying integral type, but moreover can be assigned and compared with pn532::infty.

with_inf<int> i = infty;
if (i == infty) {
    std::cout << "∞" << std::endl;
} else {
    std::cout << i << std::endl;
}

Template Parameters:

Integral – Any integral type

Comparison operators

Compares against pn532::infty (i.e. std::numeric_limits<Integral>::max()).

inline bool operator==(infty_t) const
inline bool operator!=(infty_t) const

Public Functions

with_inf() = default

Zero-initializes the underlying value v.

inline with_inf(infty_t)

Initializes v to std::numeric_limits<Integral>::max().

inline with_inf(Integral n)

Implicitly wraps n.

with_inf(bool) = delete

Prevents accidental cast from bool.

inline operator Integral() const

Implicitly converts back to integral.

inline with_inf &operator=(infty_t)

Assigns the maximum.

Public Members

Integral v = Integral{}

Integral member.