From a4b63b27a4c9f73c5abce77ba70e027a4c04b903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rimas=20Misevi=C4=8Dius?= Date: Sun, 27 Oct 2024 08:43:47 +0200 Subject: [PATCH] Improve ATL/MFC string input support for C++17 Add support for any strings derived from CSimpleStringT when using C++17 compilers. --- include/upa/str_arg.h | 6 ++++++ include/upa/url_for_atl.h | 21 +++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/upa/str_arg.h b/include/upa/str_arg.h index 5c19a3e..509918f 100644 --- a/include/upa/str_arg.h +++ b/include/upa/str_arg.h @@ -49,6 +49,12 @@ constexpr bool is_size_type_v = std::is_convertible_v || std::is_convertible_v; +// See: https://en.cppreference.com/w/cpp/concepts/derived_from +template +constexpr bool is_derived_from_v = + std::is_base_of_v && + std::is_convertible_v; + // string args helper class diff --git a/include/upa/url_for_atl.h b/include/upa/url_for_atl.h index 9b08dbf..03e6a42 100644 --- a/include/upa/url_for_atl.h +++ b/include/upa/url_for_atl.h @@ -14,7 +14,7 @@ #ifdef UPA_CPP_20 # include #else -# include +# include #endif namespace upa { @@ -43,17 +43,14 @@ struct str_arg_char : public str_arg_char_for_atl {}; #else // UPA_CPP_20 -template -struct str_arg_char> : - public str_arg_char_for_atl> {}; - -template -struct str_arg_char> : - public str_arg_char_for_atl> {}; - -template -struct str_arg_char> : - public str_arg_char_for_atl> {}; +// CStringT and CFixedStringT are derived from CSimpleStringT +template +struct str_arg_char> || + is_derived_from_v> || + is_derived_from_v> || + is_derived_from_v> + >> : public str_arg_char_for_atl {}; #endif // UPA_CPP_20