mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 05:22:30 +02:00
util: Make Assume() usable as unary expression
This commit is contained in:
parent
d099894ec1
commit
fa4cebadcf
@ -76,6 +76,9 @@ BOOST_AUTO_TEST_CASE(util_check)
|
|||||||
const int two = *Assert(p_two);
|
const int two = *Assert(p_two);
|
||||||
Assert(two == 2);
|
Assert(two == 2);
|
||||||
Assert(true);
|
Assert(true);
|
||||||
|
// Check that Assume can be used as unary expression
|
||||||
|
const bool result{Assume(two == 2)};
|
||||||
|
Assert(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(util_criticalsection)
|
BOOST_AUTO_TEST_CASE(util_criticalsection)
|
||||||
|
@ -69,7 +69,7 @@ T get_pure_r_value(T&& val)
|
|||||||
#ifdef ABORT_ON_FAILED_ASSUME
|
#ifdef ABORT_ON_FAILED_ASSUME
|
||||||
#define Assume(val) Assert(val)
|
#define Assume(val) Assert(val)
|
||||||
#else
|
#else
|
||||||
#define Assume(val) ((void)(val))
|
#define Assume(val) ([&]() -> decltype(get_pure_r_value(val)) { auto&& check = (val); return std::forward<decltype(get_pure_r_value(val))>(check); }())
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // BITCOIN_UTIL_CHECK_H
|
#endif // BITCOIN_UTIL_CHECK_H
|
||||||
|
Loading…
Reference in New Issue
Block a user