From 6bea3d37921dbe890e6a1e1917f424869f776541 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++11 ... C++17 Add support for any strings derived from CSimpleStringT when using C++11 ... C++17 compilers. --- include/upa/str_arg.h | 7 +++++++ include/upa/url_for_atl.h | 21 +++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/include/upa/str_arg.h b/include/upa/str_arg.h index a3d5df9..9df9225 100644 --- a/include/upa/str_arg.h +++ b/include/upa/str_arg.h @@ -59,6 +59,13 @@ struct is_size_type : std::integral_constant::value > {}; +// See: https://en.cppreference.com/w/cpp/concepts/derived_from +template +struct is_derived_from : std::integral_constant::value && + std::is_convertible::value +> {}; + // string args helper class diff --git a/include/upa/url_for_atl.h b/include/upa/url_for_atl.h index 9b08dbf..82e3ae1 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>::value || + is_derived_from>::value || + is_derived_from>::value || + is_derived_from>::value + >::type> : public str_arg_char_for_atl {}; #endif // UPA_CPP_20