Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- template<class T>
- struct output_span_impl{
- void* ud;
- void (*init)(void*, T** beg, T** mid, T** end);
- void (*write_back)(void*, T* mid);
- void (*grow)(void*, T** beg, T** mid, T** end);
- };
- template<class T>
- struct output_span{
- output_span(output_span_impl<T> impl):
- impl(impl){
- impl(impl.ud, &beg, &mid, &end);
- }
- ~output_span(){
- impl.write_back(impl, mid);
- }
- void push_back(T val){
- if (mid == end){
- impl.grow(impl.ud, &beg, &mid, &end);
- }
- *mid = val;
- mid++;
- }
- ...
- output_span_impl<T> impl;
- T* beg;
- T* mid;
- T* end;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement