string: add strncpy for fixed-size buffers

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2023-12-22 11:41:02 +01:00
parent 61bf25ac6a
commit 024f3f7172

View File

@ -1503,6 +1503,22 @@ namespace stdex
} }
} }
///
/// Copy zero-terminated string
///
/// \param[in] dst Destination string
/// \param[in] src Source string
///
/// \return Number of code units excluding zero terminator in the dst string after the operation.
///
template <class T1, size_t N1, class T2, size_t N2>
inline size_t strncpy(
_Out_ _Post_maybez_ T1 (&dst)[N1],
_In_ const T2 (&src)[N2])
{
return strncpy(dst, N1, src, N2);
}
/// ///
/// Append zero-terminated string /// Append zero-terminated string
/// ///