diff --git a/include/string_span.h b/include/string_span.h index a451314..feb5ac6 100644 --- a/include/string_span.h +++ b/include/string_span.h @@ -111,28 +111,28 @@ inline span ensure_z(T* const & sz, std::ptrdiff_t max = PTRDI // TODO (neilmac) there is probably a better template-magic way to get the const and non-const overloads to share an implementation inline span ensure_z(char* const& sz, std::ptrdiff_t max) { - auto len = strnlen(sz, max); + auto len = strnlen(sz, narrow_cast(max)); Ensures(sz[len] == 0); return{ sz, static_cast(len) }; } inline span ensure_z(const char* const& sz, std::ptrdiff_t max) { - auto len = strnlen(sz, max); + auto len = strnlen(sz, narrow_cast(max)); Ensures(sz[len] == 0); return{ sz, static_cast(len) }; } inline span ensure_z(wchar_t* const& sz, std::ptrdiff_t max) { - auto len = wcsnlen(sz, max); + auto len = wcsnlen(sz, narrow_cast(max)); Ensures(sz[len] == 0); return{ sz, static_cast(len) }; } inline span ensure_z(const wchar_t* const& sz, std::ptrdiff_t max) { - auto len = wcsnlen(sz, max); + auto len = wcsnlen(sz, narrow_cast(max)); Ensures(sz[len] == 0); return{ sz, static_cast(len) }; } @@ -172,7 +172,7 @@ namespace details { std::ptrdiff_t operator()(char* const ptr, std::ptrdiff_t length) noexcept { - return narrow_cast(strnlen(ptr, length)); + return narrow_cast(strnlen(ptr, narrow_cast(length))); } }; @@ -181,7 +181,7 @@ namespace details { std::ptrdiff_t operator()(wchar_t* const ptr, std::ptrdiff_t length) noexcept { - return narrow_cast(wcsnlen(ptr, length)); + return narrow_cast(wcsnlen(ptr, narrow_cast(length))); } }; @@ -190,7 +190,7 @@ namespace details { std::ptrdiff_t operator()(const char* const ptr, std::ptrdiff_t length) noexcept { - return narrow_cast(strnlen(ptr, length)); + return narrow_cast(strnlen(ptr, narrow_cast(length))); } }; @@ -199,7 +199,7 @@ namespace details { std::ptrdiff_t operator()(const wchar_t* const ptr, std::ptrdiff_t length) noexcept { - return narrow_cast(wcsnlen(ptr, length)); + return narrow_cast(wcsnlen(ptr, narrow_cast(length))); } }; }