2#ifndef poplar_StringRef_hpp
3#define poplar_StringRef_hpp
13struct StringRef :
public ArrayRef<char> {
14 constexpr StringRef() : ArrayRef() {}
15 constexpr StringRef(
const StringRef &) =
default;
16 StringRef(std::nullptr_t) =
delete;
17 StringRef(
const std::string &s) : ArrayRef(s.data(), s.size()) {}
18 constexpr StringRef(
const char *p, std::size_t len) : ArrayRef(p, len) {}
19 StringRef(
const char *p) : ArrayRef(p, std::strlen(p)) {}
22 template <std::
size_t N>
23 constexpr StringRef(
const char (&p)[N]) : ArrayRef(p, N - 1) {}
25 std::string cloneAsString()
const {
return std::string(begin(), size()); }
27 operator std::string()
const {
return cloneAsString(); }
30inline bool operator==(StringRef l, StringRef r) {
31 if (l.size() != r.size()) {
34 return std::strncmp(l.data(), r.data(), l.size()) == 0;
37inline bool operator!=(StringRef l, StringRef r) {
return !(l == r); }
39inline bool operator<(StringRef l, StringRef r) {
42 return std::strncmp(l.data(), r.data(),
std::min(l.size(), r.size()) + 1) < 0;
45inline std::string operator+(StringRef l, StringRef r) {
47 c.reserve(l.size() + r.size());
49 c.append(r.data(), r.size());
53inline std::string &operator+=(std::string &s, StringRef r) {
54 s.append(r.begin(), r.end());
58inline std::ostream &
operator<<(std::ostream &os,
const StringRef &s) {
59 return os << s.cloneAsString();
half2 min(half2 src0, half2 src1)
Targets the f16v2min instruction.
Definition: ipu_intrinsics:384
Poplar classes and functions.
Definition: ArrayRef.hpp:14
std::ostream & operator<<(std::ostream &os, const DebugNameAndId &dnai)
Display the path name of the DebugNameAndId.