Skip to content
This repository was archived by the owner on May 28, 2019. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion include/slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ class Slice {

// Create a slice that refers to d[0,n-1].
Slice(const char* d, size_t n) : data_(d), size_(n) { }

Slice(const unsigned char* d, size_t n) : data_(reinterpret_cast<const char*>(d)), size_(n) { }

// Create a slice that refers to the contents of "s"
Slice(const std::string& s) : data_(s.data()), size_(s.size()) { }
Slice(const std::string& s) : data_(s.data()), size_(static_cast<size_t>(s.size())) { }

// Create a slice that refers to s[0,strlen(s)-1]
Slice(const char* s) : data_(s), size_(strlen(s)) { }

Slice(const unsigned char* s) : data_(reinterpret_cast<const char*>(s)), size_(strlen(reinterpret_cast<const char*>(s))) { }

// Return a pointer to the beginning of the referenced data
const char* data() const { return data_; }
Expand Down