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