[refactor]use clear concept to replace std::enable_if_t (#22801)

---------

Signed-off-by: flynn <fenglv15@mails.ucas.ac.cn>
This commit is contained in:
flynn
2023-08-12 15:10:30 +08:00
committed by GitHub
parent 2b81553879
commit 4e880288c6
17 changed files with 112 additions and 91 deletions

View File

@ -355,7 +355,8 @@ struct GetJsonNumberType {
}
}
template <typename T, std::enable_if_t<std::is_same_v<double, T>, T>* = nullptr>
template <typename T>
requires std::is_same_v<double, T>
static void handle_result(rapidjson::Value* root, T& res, uint8_t& res_null) {
if (root == nullptr || root->IsNull()) {
res = 0;
@ -371,7 +372,8 @@ struct GetJsonNumberType {
}
}
template <typename T, std::enable_if_t<std::is_same_v<int32_t, T>, T>* = nullptr>
template <typename T>
requires std::is_same_v<T, int32_t>
static void handle_result(rapidjson::Value* root, int32_t& res, uint8_t& res_null) {
if (root != nullptr && root->IsInt()) {
res = root->GetInt();
@ -380,7 +382,8 @@ struct GetJsonNumberType {
}
}
template <typename T, std::enable_if_t<std::is_same_v<int64_t, T>, T>* = nullptr>
template <typename T>
requires std::is_same_v<T, int64_t>
static void handle_result(rapidjson::Value* root, int64_t& res, uint8_t& res_null) {
if (root != nullptr && root->IsInt64()) {
res = root->GetInt64();