Remove unsafe Slice operators.

GitOrigin-RevId: 38555a755fd4252ccc25398340b7fcab542d9f3c
This commit is contained in:
levlam 2018-12-18 02:02:28 +03:00
parent a20168bdf9
commit b5e95821ad

View File

@ -85,6 +85,18 @@ class Slice {
constexpr Slice(const char (&a)[N]) : s_(a), len_(N - 1) {
}
Slice &operator=(string &&s) = delete;
template <size_t N>
constexpr Slice &operator=(char (&a)[N]) = delete;
template <size_t N>
constexpr Slice &operator=(const char (&a)[N]) {
s_ = a;
len_ = N - 1;
return *this;
}
bool empty() const;
size_t size() const;
@ -170,6 +182,18 @@ class CSlice : public Slice {
CSlice() : CSlice("") {
}
CSlice &operator=(string &&s) = delete;
template <size_t N>
constexpr CSlice &operator=(char (&a)[N]) = delete;
template <size_t N>
constexpr CSlice &operator=(const char (&a)[N]) {
s_ = a;
len_ = N - 1;
return *this;
}
const char *c_str() const {
return begin();
}