// SkSafeRange always check that a series of operations are in-range. // This check is sticky, so that if any one operation fails, the object will remember that and // return false from ok().
class SkSafeRange { public: explicitoperatorbool() const { return fOK; }
bool ok() const { return fOK; }
// checks 0 <= value <= max. // On success, returns value // On failure, returns 0 and sets ok() to false template <typename T> T checkLE(uint64_t value, T max) {
SkASSERT(static_cast<int64_t>(max) >= 0); if (value > static_cast<uint64_t>(max)) {
fOK = false;
value = 0;
} returnstatic_cast<T>(value);
}
int checkGE(int value, int min) { if (value < min) {
fOK = false;
value = min;
} return value;
}
private: bool fOK = true;
};
#endif
Messung V0.5
¤ Dauer der Verarbeitung: 0.21 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.