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