mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
normalize
is a more accurate name than sanitize
This commit is contained in:
parent
0b80ac7d02
commit
81c10b8017
@ -106,16 +106,14 @@ public:
|
|||||||
#else // VESTIGIAL, remove when no longer needed for downlevel compilers
|
#else // VESTIGIAL, remove when no longer needed for downlevel compilers
|
||||||
using handler = void (*)();
|
using handler = void (*)();
|
||||||
#endif
|
#endif
|
||||||
|
constexpr contract_group (handler h = nullptr) : chandler(normalize(h)) { }
|
||||||
constexpr contract_group (handler h = nullptr) : chandler(sanitize(h)) { }
|
constexpr auto set_handler(handler h) -> handler { auto old = chandler; chandler = normalize(h); return old; }
|
||||||
constexpr auto set_handler(handler h) -> handler { auto old = chandler; chandler = sanitize(h); return old; }
|
|
||||||
constexpr auto get_handler() const -> handler { return chandler; }
|
constexpr auto get_handler() const -> handler { return chandler; }
|
||||||
|
constexpr auto expects (bool b) -> void { assertion(b); }
|
||||||
constexpr void expects (bool b) { assertion(b); }
|
constexpr auto ensures (bool b) -> void { assertion(b); }
|
||||||
constexpr void ensures (bool b) { assertion(b); }
|
|
||||||
private:
|
private:
|
||||||
constexpr void assertion(bool b) { if (!b) chandler(); }
|
constexpr auto assertion(bool b) -> void { if (!b) chandler(); }
|
||||||
constexpr auto sanitize(handler h) -> handler { return h ? h : []()noexcept{}; }
|
constexpr auto normalize(handler h) -> handler { return h ? h : []()noexcept{}; }
|
||||||
handler chandler;
|
handler chandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user