diff --git a/include/upa/str_arg.h b/include/upa/str_arg.h index d330988..4e96180 100644 --- a/include/upa/str_arg.h +++ b/include/upa/str_arg.h @@ -36,19 +36,19 @@ using string_view = std::string_view; template struct is_char_type : std::integral_constant::value || + std::is_same_v || #ifdef __cpp_char8_t - std::is_same::value || + std::is_same_v || #endif - std::is_same::value || - std::is_same::value || - std::is_same::value + std::is_same_v || + std::is_same_v || + std::is_same_v > {}; template struct is_size_type : std::integral_constant::value || - std::is_convertible::value + std::is_convertible_v || + std::is_convertible_v > {}; @@ -62,14 +62,14 @@ class str_arg { // output value type using value_type = // wchar_t type will be converted to char16_t or char32_t type equivalent by size - typename std::conditional::value, std::conditional::type, + std::conditional_t, std::conditional_t, #ifdef __cpp_char8_t // char8_t type will be converted to char type - typename std::conditional::value, char, input_type>::type + std::conditional_t, char, input_type> #else input_type #endif - >::type; + >; // constructors str_arg(const str_arg&) noexcept = default; @@ -123,7 +123,7 @@ class str_arg { // String type helpers template -using remove_cvptr_t = typename std::remove_cv::type>::type; +using remove_cvptr_t = std::remove_cv_t>; namespace detail { // See: https://stackoverflow.com/a/9154394 @@ -170,7 +170,7 @@ struct str_arg_char : std::remove_cv { template struct str_arg_char : std::enable_if< is_size_type::value, - typename std::remove_cv::type> { + std::remove_cv_t> { template static str_arg to_str_arg(const T* s, std::size_t length) { @@ -191,7 +191,7 @@ struct str_arg_char : std::remove_cv { // one string class argument template struct str_arg_char : std::enable_if< - std::is_pointer>::value && + std::is_pointer_v> && is_size_type>::value, remove_cvptr_t>> { @@ -205,16 +205,16 @@ struct str_arg_char : std::enable_if< // String arguments helper types template -using str_arg_char_s = str_arg_char::type...>; +using str_arg_char_s = str_arg_char...>; template using str_arg_char_t = typename str_arg_char_s::type; template -using enable_if_str_arg_t = typename std::enable_if< +using enable_if_str_arg_t = std::enable_if_t< is_char_type>::value, - int>::type; + int>; // String arguments helper function @@ -229,28 +229,28 @@ inline auto make_str_arg(Args&&... args) -> str_arg> { template struct is_char8_type : std::integral_constant::value + std::is_same_v #ifdef __cpp_char8_t - || std::is_same::value + || std::is_same_v #endif > {}; template -using enable_if_str_arg_to_char8_t = typename std::enable_if< +using enable_if_str_arg_to_char8_t = std::enable_if_t< is_char8_type>::value, - int>::type; + int>; template struct is_charW_type : std::integral_constant::value || - std::is_same::value || - std::is_same::value + std::is_same_v || + std::is_same_v || + std::is_same_v > {}; template -using enable_if_str_arg_to_charW_t = typename std::enable_if< +using enable_if_str_arg_to_charW_t = std::enable_if_t< is_charW_type>::value, - int>::type; + int>; inline std::string&& make_string(std::string&& str) { diff --git a/include/upa/url.h b/include/upa/url.h index 65d631d..33399a3 100644 --- a/include/upa/url.h +++ b/include/upa/url.h @@ -1596,7 +1596,7 @@ namespace detail { template inline validation_errc url_parser::url_parse(url_serializer& urls, const CharT* first, const CharT* last, const url* base, State state_override) { - using UCharT = typename std::make_unsigned::type; + using UCharT = std::make_unsigned_t; // remove all ASCII tab or newline from URL simple_buffer buff_no_ws; @@ -2388,7 +2388,7 @@ inline void url_parser::parse_path(url_serializer& urls, const CharT* first, con template inline bool url_parser::do_path_segment(const CharT* pointer, const CharT* last, std::string& output) { - using UCharT = typename std::make_unsigned::type; + using UCharT = std::make_unsigned_t; // TODO-WARN: 2. [ 1 ... 2 ] validation error. bool success = true; @@ -2413,7 +2413,7 @@ inline bool url_parser::do_path_segment(const CharT* pointer, const CharT* last, template inline bool url_parser::do_simple_path(const CharT* pointer, const CharT* last, std::string& output) { - using UCharT = typename std::make_unsigned::type; + using UCharT = std::make_unsigned_t; // 3. of "opaque path state" // TODO-WARN: 3. [ 1 ... 2 ] validation error. diff --git a/include/upa/url_host.h b/include/upa/url_host.h index 427ea75..20a7191 100644 --- a/include/upa/url_host.h +++ b/include/upa/url_host.h @@ -157,7 +157,7 @@ inline bool contains_forbidden_host_char(const CharT* first, const CharT* last) template inline validation_errc host_parser::parse_host(const CharT* first, const CharT* last, bool is_opaque, host_output& dest) { - using UCharT = typename std::make_unsigned::type; + using UCharT = std::make_unsigned_t; // 1. Non-"file" special URL's cannot have an empty host. // 2. For "file" URL's empty host is set in the file_host_state 1.2 @@ -314,7 +314,7 @@ inline validation_errc host_parser::parse_opaque_host(const CharT* first, const //TODO: UTF-8 percent encode it using the C0 control percent-encode set //detail::append_utf8_percent_encoded(first, last, detail::CHAR_C0_CTRL, str_host); - using UCharT = typename std::make_unsigned::type; + using UCharT = std::make_unsigned_t; const CharT* pointer = first; while (pointer < last) { diff --git a/include/upa/url_ip.h b/include/upa/url_ip.h index 4e14924..7c614e9 100644 --- a/include/upa/url_ip.h +++ b/include/upa/url_ip.h @@ -133,7 +133,7 @@ inline validation_errc ipv4_parse_number(const CharT* first, const CharT* last, // template inline validation_errc ipv4_parse(const CharT* first, const CharT* last, uint32_t& ipv4) { - using UCharT = typename std::make_unsigned::type; + using UCharT = std::make_unsigned_t; // 2. If the last item in parts is the empty string, then // 1. IPv4-empty-part validation error. (TODO-WARN) diff --git a/include/upa/url_percent_encode.h b/include/upa/url_percent_encode.h index caee479..4d7de0c 100644 --- a/include/upa/url_percent_encode.h +++ b/include/upa/url_percent_encode.h @@ -425,7 +425,7 @@ inline bool append_utf8_percent_encoded_char(const CharT*& first, const CharT* l template inline void append_utf8_percent_encoded(const CharT* first, const CharT* last, const code_point_set& cpset, std::string& output) { - using UCharT = typename std::make_unsigned::type; + using UCharT = std::make_unsigned_t; for (auto it = first; it < last; ) { const auto uch = static_cast(*it); diff --git a/include/upa/url_search_params.h b/include/upa/url_search_params.h index 0f8ee23..2d43b75 100644 --- a/include/upa/url_search_params.h +++ b/include/upa/url_search_params.h @@ -41,9 +41,9 @@ template auto iterable_value(long) -> void; template -using iterable_value_t = typename std::remove_cv(0)) ->::type>::type; +>>; // is iterable over the std::pair values template @@ -51,9 +51,9 @@ struct is_iterable_pairs : is_pair> {}; // enable if `Base` is not the base class of `T` template -using enable_if_not_base_of_t = typename std::enable_if< - !std::is_base_of::type>::value, int ->::type; +using enable_if_not_base_of_t = std::enable_if_t< + !std::is_base_of_v>, int +>; } // namespace detail @@ -102,7 +102,7 @@ class url_search_params /// /// @param[in,out] other @c url_search_params object to move from url_search_params(url_search_params&& other) - noexcept(std::is_nothrow_move_constructible::value); + noexcept(std::is_nothrow_move_constructible_v); /// @brief Parsing constructor. /// @@ -120,7 +120,7 @@ class url_search_params template = 0, - typename std::enable_if::value, int>::type = 0 + std::enable_if_t::value, int> = 0 > explicit url_search_params(ConT&& cont) { for (const auto& p : cont) { @@ -447,7 +447,7 @@ inline url_search_params::url_search_params(const url_search_params& other) // Move constructor inline url_search_params::url_search_params(url_search_params&& other) - noexcept(std::is_nothrow_move_constructible::value) + noexcept(std::is_nothrow_move_constructible_v) : params_(std::move(other.params_)) , is_sorted_(other.is_sorted_) {} diff --git a/include/upa/util.h b/include/upa/util.h index 59a3caf..49c02bd 100644 --- a/include/upa/util.h +++ b/include/upa/util.h @@ -24,7 +24,7 @@ namespace upa::util { // __attribute__((no_sanitize("unsigned-integer-overflow"))). // Utility class to get unsigned (abs) max, min values of (signed) integer type -template ::type> +template > struct unsigned_limit { static constexpr UT max() noexcept { return static_cast(std::numeric_limits::max()); @@ -46,8 +46,8 @@ struct unsigned_limit { // Returns difference between a and b (a - b), if result is not representable // by the type Out - throws exception. template ::type, - typename std::enable_if::value, int>::type = 0> + typename UT = std::make_unsigned_t, + std::enable_if_t, int> = 0> #if defined(__clang__) __attribute__((no_sanitize("unsigned-integer-overflow"))) #endif @@ -56,7 +56,7 @@ inline Out checked_diff(T a, T b) { const UT diff = static_cast(static_cast(a) - static_cast(b)); if (diff <= unsigned_limit::max()) return static_cast(diff); - } else if (std::is_signed::value) { + } else if (std::is_signed_v) { // b > a ==> diff >= 1 const UT diff = static_cast(static_cast(b) - static_cast(a)); if (diff <= unsigned_limit::min()) @@ -67,7 +67,7 @@ inline Out checked_diff(T a, T b) { // Cast integer value to corresponding unsigned type -template ::type> +template > constexpr auto to_unsigned(T n) noexcept -> UT { return static_cast(n); } @@ -105,14 +105,14 @@ inline std::size_t add_sizes(std::size_t size1, std::size_t size2, std::size_t m #ifdef _MSC_VER // the value_type of dest and src are the same (char) template ::value, int>::type = 0> + std::enable_if_t, int> = 0> inline void append(std::string& dest, const StrT& src) { dest.append(src.begin(), src.end()); } // the value_type of dest and src are different template ::value, int>::type = 0> + std::enable_if_t, int> = 0> inline void append(std::string& dest, const StrT& src) { dest.reserve(add_sizes(dest.size(), src.size(), dest.max_size())); for (const auto c : src)