4#include <Rose/Exception.h>
20template<
class F,
class... Args>
23 static auto test(U *p) ->
decltype((*p)(std::declval<Args>()...), void(), std::true_type());
26 static auto test(...) ->
decltype(std::false_type());
28 static constexpr bool value =
decltype(test<F>(0))::value;
79template<
class Value,
class Predicate>
80typename std::enable_if<is_invocable<Predicate, Value>::value, Value&>::type
81affirm(Value&& value, Predicate predicate) {
87template<
class Value,
class Predicate>
88typename std::enable_if<is_invocable<Predicate, Value>::value, Value&>::type
89affirm(Value& value, Predicate predicate) {
95template<
class Value,
class Predicate>
96typename std::enable_if<is_invocable<Predicate, Value>::value, Value&>::type
97affirm(Value&& value, Predicate predicate, std::string
const& message) {
103template<
class Value,
class Predicate>
104typename std::enable_if<is_invocable<Predicate, Value>::value, Value&>::type
105affirm(Value& value, Predicate predicate, std::string
const& message) {
106 if (predicate(value))
143 throw AffirmationError(
"value does not evaluate to true in Boolean context");
151 throw AffirmationError(
"value does not evaluate to true in Boolean context");
156affirm(Value&& value, std::string
const& message) {
164affirm(Value& value, std::string
const& message) {
194template<
class Po
inter>
202template<
class Po
inter>
217#define ROSE_AFFIRM(VALUE, PREDICATE) ::Rose::affirm((VALUE), [](auto x) -> bool { return PREDICATE; })
Exceptions for value assertions.
AffirmationError(const std::string &mesg)
Construct error with message.
Base class for all ROSE exceptions.
std::enable_if< is_invocable< Predicate, Value >::value, Value & >::type affirm(Value &&value, Predicate predicate)
Test something about a value and then return it.
Pointer & notnull(Pointer &&pointer)
Check for non-null pointer.