1 //===-- str{,case}str implementation ----------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H
10 #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H
11
12 #include "src/string/memory_utils/inline_memmem.h"
13 #include "src/string/string_utils.h"
14 #include <stddef.h>
15
16 namespace LIBC_NAMESPACE {
17
18 template <typename Comp>
inline_strstr(const char * haystack,const char * needle,Comp && comp)19 LIBC_INLINE constexpr char *inline_strstr(const char *haystack,
20 const char *needle, Comp &&comp) {
21 void *result = inline_memmem(
22 static_cast<const void *>(haystack), internal::string_length(haystack),
23 static_cast<const void *>(needle), internal::string_length(needle), comp);
24 return static_cast<char *>(result);
25 }
26
27 } // namespace LIBC_NAMESPACE
28
29 #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H
30