Browse Source

improved buffers

devel
Ludovic 'Archivist' Lagouardette 4 years ago
parent
commit
f92e3b43cb
2 changed files with 25 additions and 1 deletions
  1. +1
    -1
      Makefile
  2. +24
    -0
      include/gp/buffer.hpp

+ 1
- 1
Makefile View File

@ -1,5 +1,5 @@
CXX= clang++-8
CXXFLAGS= --std=c++17 -O3 -pthread -DGP_TESTS -DFUZZ_STRENGTH=500 -pedantic -Werror \
CXXFLAGS= --std=c++17 -O0 -pthread -DGP_TESTS -DFUZZ_STRENGTH=500 -pedantic -Werror \
-Wno-unknown-attributes \
-g -fprofile-instr-generate -fcoverage-mapping
# -fsanitize=address -fno-omit-frame-pointer

+ 24
- 0
include/gp/buffer.hpp View File

@ -119,5 +119,29 @@ namespace gp{
return buffer{(T*)nullptr,(size_t)0};
}
}
buffer trim_start(size_t rm_sz)
{
if(rm_sz<=size())
{
return buffer{begin().data + rm_sz, end().data};
}
else
{
return buffer{(T*)nullptr,(size_t)0};
}
}
buffer trim_end(size_t rm_sz)
{
if(rm_sz<=size())
{
return buffer{begin().data, end().data - rm_sz};
}
else
{
return buffer{(T*)nullptr,(size_t)0};
}
}
};
}

Loading…
Cancel
Save