#pragma once namespace ss { //////////////// // all except //////////////// template struct ax { private: template bool ss_valid_impl(const T& x) const { if constexpr (sizeof...(Xs) != 0) { return x != X && ss_valid_impl(x); } return x != X; } public: bool ss_valid(const T& value) const { return ss_valid_impl(value); } const char* error() const { return "value excluded"; } }; //////////////// // none except //////////////// template struct nx { private: template bool ss_valid_impl(const T& x) const { if constexpr (sizeof...(Xs) != 0) { return x == X || ss_valid_impl(x); } return x == X; } public: bool ss_valid(const T& value) const { return ss_valid_impl(value); } const char* error() const { return "value excluded"; } }; //////////////// // greater than or equal to // greater than // less than // less than or equal to //////////////// template struct gt { bool ss_valid(const T& value) const { return value > N; } }; template struct gte { bool ss_valid(const T& value) const { return value >= N; } }; template struct lt { bool ss_valid(const T& value) const { return value < N; } }; template struct lte { bool ss_valid(const T& value) const { return value <= N; } }; //////////////// // in range //////////////// template struct ir { bool ss_valid(const T& value) const { return value >= Min && value <= Max; } }; //////////////// // out of range //////////////// template struct oor { bool ss_valid(const T& value) const { return value < Min || value > Max; } }; //////////////// // non empty //////////////// template struct ne { bool ss_valid(const T& value) const { return !value.empty(); } const char* error() const { return "empty field"; } }; } /* ss */