mirror of
https://github.com/microsoft/GSL.git
synced 2024-11-03 17:56:43 -05:00
Add workarounds for Android compiler and constexpr
test
This commit is contained in:
parent
59f38376b9
commit
d83e9ea05f
@ -102,18 +102,18 @@ namespace details
|
|||||||
|
|
||||||
class contract_group {
|
class contract_group {
|
||||||
public:
|
public:
|
||||||
using handler = void (*)() noexcept;
|
using handler = void (*)() /*noexcept*/; // TODO: make this noexcept once all supported compilers allow it
|
||||||
|
|
||||||
contract_group(handler h) { set_handler(h); }
|
constexpr contract_group(handler h) { set_handler(h); }
|
||||||
auto set_handler(handler h) -> handler { if (!h) h = []()noexcept{};
|
auto set_handler(handler h) -> handler { if (!h) h = []()noexcept{};
|
||||||
return chandler.exchange(h); }
|
return chandler.exchange(h); }
|
||||||
auto get_handler() -> handler { return chandler; }
|
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.load()(); }
|
constexpr void assertion(bool b) { if (!b) chandler.load()(); }
|
||||||
std::atomic<handler> chandler;
|
std::atomic<handler> chandler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user