summaryrefslogtreecommitdiff
path: root/externals/demangle/llvm/Demangle/StringViewExtras.h
diff options
context:
space:
mode:
Diffstat (limited to 'externals/demangle/llvm/Demangle/StringViewExtras.h')
-rw-r--r--externals/demangle/llvm/Demangle/StringViewExtras.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/externals/demangle/llvm/Demangle/StringViewExtras.h b/externals/demangle/llvm/Demangle/StringViewExtras.h
new file mode 100644
index 000000000..83685c304
--- /dev/null
+++ b/externals/demangle/llvm/Demangle/StringViewExtras.h
@@ -0,0 +1,39 @@
1//===--- StringViewExtras.h ----------*- mode:c++;eval:(read-only-mode) -*-===//
2// Do not edit! See README.txt.
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-FileCopyrightText: Part of the LLVM Project
6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7//
8//===----------------------------------------------------------------------===//
9//
10// There are two copies of this file in the source tree. The one under
11// libcxxabi is the original and the one under llvm is the copy. Use
12// cp-to-llvm.sh to update the copy. See README.txt for more details.
13//
14//===----------------------------------------------------------------------===//
15
16#ifndef DEMANGLE_STRINGVIEW_H
17#define DEMANGLE_STRINGVIEW_H
18
19#include "DemangleConfig.h"
20
21#include <string_view>
22
23DEMANGLE_NAMESPACE_BEGIN
24
25inline bool starts_with(std::string_view self, char C) noexcept {
26 return !self.empty() && *self.begin() == C;
27}
28
29inline bool starts_with(std::string_view haystack,
30 std::string_view needle) noexcept {
31 if (needle.size() > haystack.size())
32 return false;
33 haystack.remove_suffix(haystack.size() - needle.size());
34 return haystack == needle;
35}
36
37DEMANGLE_NAMESPACE_END
38
39#endif