1 //===--- StringViewExtras.h -------------------------------------*- 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 // There are two copies of this file in the source tree. The one under 10 // libcxxabi is the original and the one under llvm is the copy. Use 11 // cp-to-llvm.sh to update the copy. See README.txt for more details. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef DEMANGLE_STRINGVIEW_H 16 #define DEMANGLE_STRINGVIEW_H 17 18 #include "DemangleConfig.h" 19 20 #include <string_view> 21 22 DEMANGLE_NAMESPACE_BEGIN 23 starts_with(std::string_view self,char C)24inline bool starts_with(std::string_view self, char C) { 25 return !self.empty() && self.front() == C; 26 } 27 starts_with(std::string_view haystack,std::string_view needle)28inline bool starts_with(std::string_view haystack, std::string_view needle) { 29 return haystack.substr(0, needle.size()) == needle; 30 } 31 32 DEMANGLE_NAMESPACE_END 33 34 #endif 35