MCPcopy Create free account
hub / github.com/danielaparker/jsoncons / starts_with

Function starts_with

include/jsoncons/utility/string_utils.hpp:49–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47
48template <typename StringViewLike>
49typename std::enable_if<ext_traits::is_string_view_like<StringViewLike>::value,bool>::type
50starts_with(const StringViewLike& sv, const StringViewLike& prefix)
51{
52 using char_type = typename StringViewLike::value_type;
53
54 if (JSONCONS_UNLIKELY(sv.size() < prefix.size()))
55 {
56 return false;
57 }
58 const char_type* p = sv.data();
59 const char_type* q = prefix.data();
60 const char_type* last = prefix.data() + prefix.size();
61
62 while (q < last)
63 {
64 if (*q++ != *p++)
65 {
66 return false;
67 }
68 }
69 return true;
70}
71
72template <typename StringViewLike>
73typename std::enable_if<ext_traits::is_string_view_like<StringViewLike>::value,bool>::type

Callers 1

Calls 2

sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected