tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
strcmp.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2019 Tobias Hienzsch
3
4#ifndef TETL_CSTRING_STRCMP_HPP
5#define TETL_CSTRING_STRCMP_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 the C string lhs to the C string rhs.
15///
16/// This function starts comparing the first character of each string.
17/// If they are equal to each other, it continues with the following pairs until
18/// the characters differ or until a terminating null-character is reached.
19///
20/// \ingroup cstring
21[[nodiscard]] constexpr auto strcmp(char const* lhs, char const* rhs) -> int
22{
23#if __has_builtin(__builtin_strcmp)
24 return __builtin_strcmp(lhs, rhs);
25#else
26 return etl::detail::strcmp<char>(lhs, rhs);
27#endif
28}
29
30} // namespace etl
31
32#endif // TETL_CSTRING_STRCMP_HPP
constexpr auto strcmp(char const *lhs, char const *rhs) -> int
Compares the C string lhs to the C string rhs.
Definition strcmp.hpp:21
Definition adjacent_find.hpp:9