xref: /llvm-project/libc/src/string/memory_utils/inline_strstr.h (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
11f578347SGuillaume Chatelet //===-- str{,case}str implementation ----------------------------*- C++ -*-===//
21f578347SGuillaume Chatelet //
31f578347SGuillaume Chatelet // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
41f578347SGuillaume Chatelet // See https://llvm.org/LICENSE.txt for license information.
51f578347SGuillaume Chatelet // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
61f578347SGuillaume Chatelet //
71f578347SGuillaume Chatelet //===----------------------------------------------------------------------===//
81f578347SGuillaume Chatelet 
91f578347SGuillaume Chatelet #ifndef LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H
101f578347SGuillaume Chatelet #define LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H
111f578347SGuillaume Chatelet 
12*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
131f578347SGuillaume Chatelet #include "src/string/memory_utils/inline_memmem.h"
141f578347SGuillaume Chatelet #include "src/string/string_utils.h"
151f578347SGuillaume Chatelet #include <stddef.h>
161f578347SGuillaume Chatelet 
17*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
181f578347SGuillaume Chatelet 
191f578347SGuillaume Chatelet template <typename Comp>
201f578347SGuillaume Chatelet LIBC_INLINE constexpr char *inline_strstr(const char *haystack,
211f578347SGuillaume Chatelet                                           const char *needle, Comp &&comp) {
221f578347SGuillaume Chatelet   void *result = inline_memmem(
231f578347SGuillaume Chatelet       static_cast<const void *>(haystack), internal::string_length(haystack),
241f578347SGuillaume Chatelet       static_cast<const void *>(needle), internal::string_length(needle), comp);
251f578347SGuillaume Chatelet   return static_cast<char *>(result);
261f578347SGuillaume Chatelet }
271f578347SGuillaume Chatelet 
28*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
291f578347SGuillaume Chatelet 
301f578347SGuillaume Chatelet #endif // LLVM_LIBC_SRC_STRING_MEMORY_UTILS_INLINE_STRSTR_H
31