From 19eb73ff543c81c6886725a20dea0060cb0c0c26 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 2 Oct 2015 14:56:27 +0200 Subject: 7.3 --- zen/string_traits.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'zen/string_traits.h') 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 //strlen #include "type_tools.h" //uniform access to string-like types, both classes and character arrays @@ -143,19 +144,22 @@ struct GetCharType : ResultType::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 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::value || IsSameType::value, ""); size_t len = 0; while (*str++ != 0) ++len; return len; } +#endif template ::isStringClass>::Type> inline const typename GetCharType::Type* strBegin(const S& str) //SFINAE: T must be a "string" -- cgit