-
-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improve: replace type traits with STL #785
Conversation
Looks like Windows builds are broken, they're failing even on master |
we will analyze, but for now we can ignore this error and merge, just set this condition to not compile in MSVC. |
@@ -74,7 +72,7 @@ namespace stdext | |||
template<typename... Args> | |||
int snprintf(char* s, size_t maxlen, const char* format, const Args&... args) | |||
{ | |||
std::tuple<typename replace_extent<Args>::type...> tuple(args...); | |||
std::tuple<std::decay_t<Args>...> tuple(args...); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1>D:\programacao\jogos\tibia\otclient\src\framework\stdext\format.h(75,48): error C2661: 'std::tuple<int,char *,CHAR *,unsigned __int64,unsigned __int64 >::tuple': no overloaded function takes 5 arguments
1>D:\programacao\jogos\tibia\otclient\src\framework\stdext\format.h(75,48): error C2661: 'std::tuple<int,char *,unsigned __int64>::tuple': no overloaded function takes 3 arguments
1>D:\programacao\jogos\tibia\otclient\src\framework\stdext\format.h(75,48): error C2665: 'std::tuple<char *>::tuple': no overloaded function can convert all types of arguments
possible fix: (put condition to not compile in MSVC)
#ifndef _MSC_VER
// Improved snprintf that accepts std::string and other types
template<typename... Args>
int snprintf(char* s, size_t maxlen, const char* format, const Args&... args)
{
std::tuple<std::decay_t<Args>...> tuple(args...);
return expand_snprintf<std::tuple_size_v<decltype(tuple)>>::call(s, maxlen, format, tuple);
}
template<typename... Args>
int snprintf(char* s, size_t maxlen, const char* format)
{
std::strncpy(s, format, maxlen);
s[maxlen - 1] = 0;
return strlen(s);
}
#endif
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ranisalt
I did the review and forgot to apply it. 😅
@ranisalt |
Description
Since C++20 is enabled, these type traits are included in the standard library and don't need to be implemented here.
How Has This Been Tested
Checklist