Added Buffer::Buffer(iter, iter) constructor overload

This commit is contained in:
accelerated
2018-12-02 14:42:02 -05:00
parent 57bddabfd0
commit 0b7931bfb8
3 changed files with 10 additions and 2 deletions

View File

@@ -81,6 +81,11 @@ public:
throw Exception("Invalid buffer configuration");
}
}
template <typename Iter>
Buffer(const Iter first, Iter last)
: Buffer(&*first, std::distance(first, last)) {
}
/**
* Constructs a buffer from a vector

View File

@@ -260,8 +260,7 @@ HeaderType HeaderList<HeaderType>::at(size_t index) const {
if (error != RD_KAFKA_RESP_ERR_NO_ERROR) {
throw Exception(error.to_string());
}
//Use 'Buffer' to implicitly convert to 'BufferType'
return HeaderType(name, Buffer(value, size));
return HeaderType(name, BufferType(value, value + size));
}
template <typename HeaderType>