mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-06 10:46:18 +08:00
Use auto for the template parameters
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user