tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
wcsncpy.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2020 Tobias Hienzsch
3
4#ifndef TETL_CWCHAR_WCSNCPY_HPP
5#define TETL_CWCHAR_WCSNCPY_HPP
6
7#include <etl/_contracts/check.hpp>
8#include <etl/_cstddef/size_t.hpp>
9#include <etl/_strings/cstr.hpp>
10
11namespace etl {
12
13/// \brief Copies at most count characters of the wide string pointed to by src
14/// (including the terminating null wide character) to wide character array
15/// pointed to by dest.
16///
17/// \details If count is reached before the entire string src was copied, the
18/// resulting character array is not null-terminated. If, after copying the
19/// terminating null character from src, count is not reached, additional null
20/// characters are written to dest until the total of count characters have
21/// been written. If the strings overlap, the behavior is undefined.
22///
23/// \returns dest
24constexpr auto wcsncpy(wchar_t* dest, wchar_t const* src, etl::size_t const count) -> wchar_t*
25{
26 TETL_PRECONDITION(dest != nullptr);
27 TETL_PRECONDITION(src != nullptr);
28 return etl::detail::strncpy(dest, src, count);
29}
30
31} // namespace etl
32
33#endif // TETL_CWCHAR_WCSNCPY_HPP
Definition adjacent_find.hpp:9
constexpr auto wcsncpy(wchar_t *dest, wchar_t const *src, etl::size_t const count) -> wchar_t *
Copies at most count characters of the wide string pointed to by src (including the terminating null ...
Definition wcsncpy.hpp:24