#ifndef RFL_CONSTRAINTS_HPP_ #define RFL_CONSTRAINTS_HPP_ #include "rfl/Result.hpp" namespace rfl { template struct greater_than { template static Result check(T _value) noexcept { if (_value <= static_cast(_threshold)) { return Error("Value expected to be greater than " + std::to_string(_threshold) + ", but got " + std::to_string(_value) + "."); } return _value; } }; template struct less_than { template static Result check(T _value) noexcept { if (_value >= static_cast(_threshold)) { return Error("Value expected to be less than " + std::to_string(_threshold) + ", but got " + std::to_string(_value) + "."); } return _value; } }; /// Requires that all of the contraints C and Cs be true. template struct all_of { template static rfl::Result check(T _value) noexcept { return check_impl(_value); } private: template static rfl::Result check_impl(T _value) noexcept { if constexpr (sizeof...(Tail) == 0) { return Head::check(_value); } else { return Head::check(_value).and_then(check_impl); } } }; /// Requires that any of the contraints C and Cs be true. // ... } // namespace rfl #endif