tetl
0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
memchr.hpp
Go to the documentation of this file.
1
// SPDX-License-Identifier: BSL-1.0
2
3
#ifndef TETL_CSTRING_MEMCHR_HPP
4
#define TETL_CSTRING_MEMCHR_HPP
5
6
#include <
etl/_cstddef/size_t.hpp
>
7
#include <
etl/_strings/cstr.hpp
>
8
9
namespace
etl
{
10
13
28
[[nodiscard]]
inline
auto
memchr
(
void
* ptr,
int
ch,
etl::size_t
n) ->
void
*
29
{
30
#if defined(__clang__)
31
return
__builtin_memchr(ptr, ch, n);
32
#else
33
auto
* p =
static_cast<
unsigned
char
*
>
(ptr);
34
return
etl::detail::memchr(p,
static_cast<
unsigned
char
>
(ch), n);
35
#endif
36
}
37
38
[[nodiscard]]
inline
auto
memchr
(
void
const
* ptr,
int
ch,
etl::size_t
n) ->
void
const
*
39
{
40
#if defined(__clang__)
41
return
__builtin_memchr(ptr, ch, n);
42
#else
43
auto
const
*
const
p =
static_cast<
unsigned
char
const*
>
(ptr);
44
auto
const
c =
static_cast<
unsigned
char
>
(ch);
45
return
etl::detail::memchr<unsigned char const, etl::size_t>(p, c, n);
46
#endif
47
}
48
50
51
}
// namespace etl
52
53
#endif
// TETL_CSTRING_MEMCHR_HPP
cstr.hpp
etl::memchr
auto memchr(void *ptr, int ch, etl::size_t n) -> void *
Converts ch to unsigned char and locates the first occurrence of that value in the initial count char...
Definition
memchr.hpp:28
etl
Definition
adjacent_find.hpp:8
etl::size_t
TETL_BUILTIN_SIZET size_t
etl::size_t is the unsigned integer type of the result of the sizeof operator.
Definition
size_t.hpp:14
size_t.hpp
include
etl
_cstring
memchr.hpp
Generated on Sat Mar 8 2025 16:19:59 for tetl by
1.14.0