Use auto for the template parameters

This commit is contained in:
Patrick Urbanke
2023-11-03 22:10:18 +01:00
parent 2f76dc5b94
commit 720c15762b
5 changed files with 15 additions and 15 deletions
+6 -6
View File
@@ -5,7 +5,7 @@
namespace rfl {
template <double _threshold>
template <auto _threshold>
struct EqualTo {
template <class T>
static Result<T> validate(T _value) noexcept {
@@ -19,7 +19,7 @@ struct EqualTo {
}
};
template <double _threshold>
template <auto _threshold>
struct Minimum {
template <class T>
static Result<T> validate(T _value) noexcept {
@@ -33,7 +33,7 @@ struct Minimum {
}
};
template <double _threshold>
template <auto _threshold>
struct ExclusiveMinimum {
template <class T>
static Result<T> validate(T _value) noexcept {
@@ -47,7 +47,7 @@ struct ExclusiveMinimum {
}
};
template <double _threshold>
template <auto _threshold>
struct Maximum {
template <class T>
static Result<T> validate(T _value) noexcept {
@@ -61,7 +61,7 @@ struct Maximum {
}
};
template <double _threshold>
template <auto _threshold>
struct ExclusiveMaximum {
template <class T>
static Result<T> validate(T _value) noexcept {
@@ -75,7 +75,7 @@ struct ExclusiveMaximum {
}
};
template <double _threshold>
template <auto _threshold>
struct NotEqualTo {
template <class T>
static Result<T> validate(T _value) noexcept {
+1 -1
View File
@@ -10,7 +10,7 @@ void test_all_of() {
std::cout << "test_all_of" << std::endl;
using Age = rfl::Validator<unsigned int,
rfl::AllOf<rfl::Minimum<0.>, rfl::Maximum<130.>>>;
rfl::AllOf<rfl::Minimum<0>, rfl::Maximum<130>>>;
struct Person {
rfl::Field<"firstName", std::string> first_name;
+2 -2
View File
@@ -11,8 +11,8 @@ void test_any_of() {
using Age = rfl::Validator<
unsigned int,
rfl::AnyOf<rfl::AllOf<rfl::Minimum<0.>, rfl::Maximum<10.>>,
rfl::AllOf<rfl::Minimum<40.>, rfl::Maximum<130.>>>>;
rfl::AnyOf<rfl::AllOf<rfl::Minimum<0>, rfl::Maximum<10>>,
rfl::AllOf<rfl::Minimum<40>, rfl::Maximum<130>>>>;
struct Person {
rfl::Field<"firstName", std::string> first_name;
+2 -2
View File
@@ -11,8 +11,8 @@ void test_one_of() {
using Age = rfl::Validator<
unsigned int,
rfl::OneOf<rfl::AllOf<rfl::Minimum<0.>, rfl::Maximum<10.>>,
rfl::AllOf<rfl::Minimum<40.>, rfl::Maximum<130.>>>>;
rfl::OneOf<rfl::AllOf<rfl::Minimum<0>, rfl::Maximum<10>>,
rfl::AllOf<rfl::Minimum<40>, rfl::Maximum<130>>>>;
struct Person {
rfl::Field<"firstName", std::string> first_name;
+4 -4
View File
@@ -15,10 +15,10 @@ void test_size() {
rfl::Field<"firstName", std::string> first_name;
rfl::Field<"lastName", std::string> last_name;
rfl::Field<"birthday", rfl::Timestamp<"%Y-%m-%d">> birthday;
rfl::Field<"children",
rfl::Validator<
std::vector<Person>,
rfl::Size<rfl::AnyOf<rfl::EqualTo<0.>, rfl::EqualTo<3.>>>>>
rfl::Field<
"children",
rfl::Validator<std::vector<Person>,
rfl::Size<rfl::AnyOf<rfl::EqualTo<0>, rfl::EqualTo<3>>>>>
children;
};