mirror of
https://github.com/microsoft/GSL.git
synced 2025-01-18 09:44:59 -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 (*)();
|
||||
#endif
|
||||
|
||||
contract_group (handler h) { set_handler(h); }
|
||||
auto set_handler(handler h) -> handler { return std::exchange(chandler, h ? h : []()noexcept{}); }
|
||||
auto get_handler() -> handler { return chandler; }
|
||||
constexpr contract_group (handler h) { set_handler(h); }
|
||||
constexpr auto set_handler(handler h) -> handler { return std::exchange(chandler, h ? h : []()noexcept{}); }
|
||||
constexpr auto get_handler() -> handler { return chandler; }
|
||||
|
||||
void expects (bool b) { assertion(b); }
|
||||
void ensures (bool b) { assertion(b); }
|
||||
constexpr void expects (bool b) { assertion(b); }
|
||||
constexpr void ensures (bool b) { assertion(b); }
|
||||
private:
|
||||
void assertion(bool b) { if (!b) chandler(); }
|
||||
constexpr void assertion(bool b) { if (!b) chandler(); }
|
||||
handler chandler;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user