diff options
author | Daniel Wilhelm <daniel@wili.li> | 2015-10-02 14:56:27 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2015-10-02 14:56:27 +0200 |
commit | 19eb73ff543c81c6886725a20dea0060cb0c0c26 (patch) | |
tree | 91442c0fdb9cac90c75dfb6bb84def9df297cd77 /zen/string_traits.h | |
parent | 7.2 (diff) | |
download | FreeFileSync-19eb73ff543c81c6886725a20dea0060cb0c0c26.tar.gz FreeFileSync-19eb73ff543c81c6886725a20dea0060cb0c0c26.tar.bz2 FreeFileSync-19eb73ff543c81c6886725a20dea0060cb0c0c26.zip |
7.3
Diffstat (limited to 'zen/string_traits.h')
-rw-r--r-- | zen/string_traits.h | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/zen/string_traits.h b/zen/string_traits.h index 5f91bdc4..add53d3a 100644 --- a/zen/string_traits.h +++ b/zen/string_traits.h @@ -7,6 +7,7 @@ #ifndef STRING_TRAITS_HEADER_813274321443234 #define STRING_TRAITS_HEADER_813274321443234 +#include <cstring> //strlen #include "type_tools.h" //uniform access to string-like types, both classes and character arrays @@ -143,19 +144,22 @@ struct GetCharType : ResultType<typename implementation::StringTraits<T>::CharTy namespace implementation { +//strlen/wcslen are vectorized since VS14 CTP3 +inline size_t cStringLength(const char* str) { return std::strlen(str); } +inline size_t cStringLength(const wchar_t* str) { return std::wcslen(str); } + +//no significant perf difference for "comparison" test case between cStringLength/wcslen: +#if 0 template <class C> inline -size_t cStringLength(const C* str) //naive implementation seems somewhat faster than "optimized" strlen/wcslen! +size_t cStringLength(const C* str) { -#if defined _MSC_VER && _MSC_VER > 1800 - static_assert(false, "strlen/wcslen are vectorized in VS14 CTP3 -> test again!"); -#endif - static_assert(IsSameType<C, char>::value || IsSameType<C, wchar_t>::value, ""); size_t len = 0; while (*str++ != 0) ++len; return len; } +#endif template <class S, typename = typename EnableIf<implementation::StringTraits<S>::isStringClass>::Type> inline const typename GetCharType<S>::Type* strBegin(const S& str) //SFINAE: T must be a "string" |