From e2ec706c561184a933417a5f0b3bc382b09d5d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rimas=20Misevi=C4=8Dius?= Date: Tue, 22 Oct 2024 23:41:49 +0300 Subject: [PATCH] Modernise: Use variable templates --- include/upa/str_arg.h | 29 +++++++++++++---------------- include/upa/url_search_params.h | 4 ++-- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/include/upa/str_arg.h b/include/upa/str_arg.h index 4e96180..9e6e643 100644 --- a/include/upa/str_arg.h +++ b/include/upa/str_arg.h @@ -35,21 +35,19 @@ using string_view = std::string_view; // Supported char and size types template -struct is_char_type : std::integral_constant || #ifdef __cpp_char8_t std::is_same_v || #endif std::is_same_v || std::is_same_v || - std::is_same_v -> {}; + std::is_same_v; template -struct is_size_type : std::integral_constant || - std::is_convertible_v -> {}; + std::is_convertible_v; // string args helper class @@ -169,7 +167,7 @@ struct str_arg_char : std::remove_cv { // pointer and size template struct str_arg_char : std::enable_if< - is_size_type::value, + is_size_type_v, std::remove_cv_t> { template @@ -192,7 +190,7 @@ struct str_arg_char : std::remove_cv { template struct str_arg_char : std::enable_if< std::is_pointer_v> && - is_size_type>::value, + is_size_type_v>, remove_cvptr_t>> { template @@ -213,7 +211,7 @@ using str_arg_char_t = typename str_arg_char_s::type; template using enable_if_str_arg_t = std::enable_if_t< - is_char_type>::value, + is_char_type_v>, int>; @@ -228,28 +226,27 @@ inline auto make_str_arg(Args&&... args) -> str_arg> { // Convert to std::string or string_view template -struct is_char8_type : std::integral_constant #ifdef __cpp_char8_t || std::is_same_v #endif -> {}; +; template using enable_if_str_arg_to_char8_t = std::enable_if_t< - is_char8_type>::value, + is_char8_type_v>, int>; template -struct is_charW_type : std::integral_constant || std::is_same_v || - std::is_same_v -> {}; + std::is_same_v; template using enable_if_str_arg_to_charW_t = std::enable_if_t< - is_charW_type>::value, + is_charW_type_v>, int>; diff --git a/include/upa/url_search_params.h b/include/upa/url_search_params.h index 2d43b75..2f1e43b 100644 --- a/include/upa/url_search_params.h +++ b/include/upa/url_search_params.h @@ -47,7 +47,7 @@ using iterable_value_t = std::remove_cv_t -struct is_iterable_pairs : is_pair> {}; +constexpr bool is_iterable_pairs_v = is_pair>::value; // enable if `Base` is not the base class of `T` template @@ -120,7 +120,7 @@ class url_search_params template = 0, - std::enable_if_t::value, int> = 0 + std::enable_if_t, int> = 0 > explicit url_search_params(ConT&& cont) { for (const auto& p : cont) {