tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
strncmp.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_CSTRING_STRNCMP_HPP
5#define TETL_CSTRING_STRNCMP_HPP
6
7#include <etl/_cstddef/size_t.hpp>
8#include <etl/_strings/cstr.hpp>
9
10namespace etl {
11
12/// Compares at most count characters of two possibly null-terminated
13/// arrays. The comparison is done lexicographically. Characters following the
14/// null character are not compared.
15///
16/// The behavior is undefined when access occurs past the end of either
17/// array lhs or rhs. The behavior is undefined when either lhs or rhs is the
18/// null pointer.
19///
20/// \ingroup cstring
21[[nodiscard]] constexpr auto strncmp(char const* lhs, char const* rhs, etl::size_t count) -> int
22{
23#if defined(__clang__)
24 return __builtin_strncmp(lhs, rhs, count);
25#else
26 return etl::detail::strncmp<char, etl::size_t>(lhs, rhs, count);
27#endif
28}
29
30} // namespace etl
31
32#endif // TETL_CSTRING_STRNCMP_HPP
constexpr auto strncmp(char const *lhs, char const *rhs, etl::size_t count) -> int
Compares at most count characters of two possibly null-terminated arrays. The comparison is done lexi...
Definition strncmp.hpp:21
Definition adjacent_find.hpp:9