Unverified Commit 54e2bc98 authored by Dennis Jenkins's avatar Dennis Jenkins Committed by GitHub

Merge pull request #680 from win32asm/data_access_fix

Address array and vector storage through .data()
parents 4cbc4002 6ad622e8
...@@ -159,12 +159,12 @@ public: ...@@ -159,12 +159,12 @@ public:
} }
RawBuffer buffer() const { RawBuffer buffer() const {
return RawBuffer((const char *)data_.data(), pptr() - &data_[0]); return RawBuffer(data_.data(), pptr() - data_.data());
} }
void clear() { void clear() {
data_.clear(); // reset stream buffer to the whole backing storage.
this->setp(&data_[0], &data_[0] + data_.capacity()); this->setp(data_.data(), data_.data() + data_.size());
} }
protected: protected:
......
...@@ -142,7 +142,7 @@ template <typename T, size_t N> struct ViewBuilder<std::array<T, N>> { ...@@ -142,7 +142,7 @@ template <typename T, size_t N> struct ViewBuilder<std::array<T, N>> {
if (size > arr.size()) if (size > arr.size())
throw std::invalid_argument("out of bounds size"); throw std::invalid_argument("out of bounds size");
return View<T>(&arr[0], size); return View<T>(arr.data(), size);
} }
}; };
...@@ -170,7 +170,7 @@ template <typename T> struct ViewBuilder<std::vector<T>> { ...@@ -170,7 +170,7 @@ template <typename T> struct ViewBuilder<std::vector<T>> {
if (size > vec.size()) if (size > vec.size())
throw std::invalid_argument("out of bounds size"); throw std::invalid_argument("out of bounds size");
return View<T>(&vec[0], size); return View<T>(vec.data(), size);
} }
}; };
......
...@@ -28,7 +28,7 @@ static constexpr const char *UA = "pistache/0.1"; ...@@ -28,7 +28,7 @@ static constexpr const char *UA = "pistache/0.1";
namespace { namespace {
std::pair<StringView, StringView> splitUrl(const std::string &url) { std::pair<StringView, StringView> splitUrl(const std::string &url) {
RawStreamBuf<char> buf(const_cast<char *>(&url[0]), url.size()); RawStreamBuf<char> buf(const_cast<char *>(url.data()), url.size());
StreamCursor cursor(&buf); StreamCursor cursor(&buf);
match_string("http://", cursor); match_string("http://", cursor);
......
...@@ -95,7 +95,7 @@ void DynamicStreamBuf::reserve(size_t size) { ...@@ -95,7 +95,7 @@ void DynamicStreamBuf::reserve(size_t size) {
size = maxSize; size = maxSize;
const size_t oldSize = data_.size(); const size_t oldSize = data_.size();
data_.resize(size); data_.resize(size);
this->setp(&data_[0] + oldSize, &data_[0] + size); this->setp(data_.data() + oldSize, data_.data() + size);
} }
bool StreamCursor::advance(size_t count) { bool StreamCursor::advance(size_t count) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment