tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
strlen.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2// SPDX-FileCopyrightText: Copyright (C) 2021 Tobias Hienzsch
3
4#ifndef TETL_CSTRING_STRLEN_HPP
5#define TETL_CSTRING_STRLEN_HPP
6
7#include <etl/_config/all.hpp>
8
9#include <etl/_cstddef/size_t.hpp>
10#include <etl/_strings/cstr.hpp>
11#include <etl/_type_traits/is_constant_evaluated.hpp>
12
13namespace etl {
14
15/// Returns the length of the C string str.
16/// \ingroup cstring
17[[nodiscard]] constexpr auto strlen(char const* str) -> etl::size_t
18{
20#if __has_builtin(__builtin_strlen)
21 return __builtin_strlen(str);
22#endif
23 }
24 return etl::detail::strlen<char, etl::size_t>(str);
25}
26
27} // namespace etl
28
29#endif // TETL_CSTRING_STRLEN_HPP
constexpr auto strlen(char const *str) -> etl::size_t
Returns the length of the C string str.
Definition strlen.hpp:17
Definition adjacent_find.hpp:9
constexpr auto is_constant_evaluated() noexcept -> bool
Detects whether the function call occurs within a constant-evaluated context. Returns true if the eva...
Definition is_constant_evaluated.hpp:17