diff --git a/include/stdex/string.hpp b/include/stdex/string.hpp index 89f36e732..81fd4131d 100644 --- a/include/stdex/string.hpp +++ b/include/stdex/string.hpp @@ -356,6 +356,26 @@ namespace stdex return z; } + /// + /// Binary compare two strings + /// + /// \param[in] str1 String 1 + /// \param[in] str2 String 2 + /// + /// \return Negative if str1str2; zero if str1==str2 + /// + template + inline int strcmp(const T1* str1, const T2* str2) + { + _Assume_(str1 && str2); + T1 a; T2 b; + for (size_t i = 0; (a = str1[i]) | (b = str2[i]); ++i) { + if (a > b) return +1; + if (a < b) return -1; + } + return 0; + } + /// /// Binary compare two strings ///