mirror of
https://github.com/microsoft/GSL.git
synced 2025-01-18 17:55:01 -05:00
Make contract_group
a literal type
This commit is contained in:
parent
9033021831
commit
b77eaa87ee
@ -109,14 +109,14 @@ public:
|
|||||||
using handler = void (*)();
|
using handler = void (*)();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
contract_group (handler h) { set_handler(h); }
|
constexpr contract_group (handler h) { set_handler(h); }
|
||||||
auto set_handler(handler h) -> handler { return std::exchange(chandler, h ? h : []()noexcept{}); }
|
constexpr auto set_handler(handler h) -> handler { return std::exchange(chandler, h ? h : []()noexcept{}); }
|
||||||
auto get_handler() -> handler { return chandler; }
|
constexpr auto get_handler() -> handler { return chandler; }
|
||||||
|
|
||||||
void expects (bool b) { assertion(b); }
|
constexpr void expects (bool b) { assertion(b); }
|
||||||
void ensures (bool b) { assertion(b); }
|
constexpr void ensures (bool b) { assertion(b); }
|
||||||
private:
|
private:
|
||||||
void assertion(bool b) { if (!b) chandler(); }
|
constexpr void assertion(bool b) { if (!b) chandler(); }
|
||||||
handler chandler;
|
handler chandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user