In the Go language, there is a function func (* Buffer) Next, which takes from the Buffer a slice (array) of n elements.
276 // Next returns a slice containing the next n bytes from the buffer, 277 // advancing the buffer as if the bytes had been returned by Read. 278 // If there are fewer than n bytes in the buffer, Next returns the entire buffer. 279 // The slice is only valid until the next call to a read or write method. 280 func (b *Buffer) Next(n int) []byte { 281 b.lastRead = opInvalid 282 m := b.Len() 283 if n > m { 284 n = m 285 } 286 data := b.buf[b.off : b.off+n] 287 b.off += n 288 if n > 0 { 289 b.lastRead = opRead 290 } 291 return data 292 } How to implement a similar thing using Poco / FIFOBuffer.h
#include "Poco/FIFOBuffer.h" #include "Poco/Buffer.h" using Poco::FIFOBuffer; using Poco::Buffer; void main() { char* qr = ""; std::string str = "test"; FIFOBuffer buf(12); buf.write(str.c_str(), 4); std::cout << buf[0]; // t buf.read(qr, 1); // прекращена работа программы // std::memcpy(pBuffer, _buffer.begin() + _begin, length * sizeof(T)); Вот здесь вылетает. }