Skip to content

Instantly share code, notes, and snippets.

@eao197
Created January 12, 2019 12:39
Show Gist options
  • Save eao197/58ebecdac294281c3d2b0c1c781337c5 to your computer and use it in GitHub Desktop.
Save eao197/58ebecdac294281c3d2b0c1c781337c5 to your computer and use it in GitHub Desktop.
More or less valid C++ syntax for aensidhe example
// Source: https://aensidhe.ru/blog/readonlyspan-readonlysequence-c++
template<class TElement>
class Parser {
private:
const IMsgPackParser<TElement> elementParser_;
template<template<class> Container>
void Read(const Container<byte> & source, Span<TElement> & array, size_t & readSize) {
for(size_t i = 0u; i != array.Length(); ++i) {
size_t temp;
array[i] = elementParser_.Parse(source.Slice(readSize), temp);
readSize += temp;
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment