diff options
Diffstat (limited to 'decoder/sentences.h')
-rwxr-xr-x | decoder/sentences.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/decoder/sentences.h b/decoder/sentences.h index 6ab216bf..482d3be9 100755 --- a/decoder/sentences.h +++ b/decoder/sentences.h @@ -7,8 +7,30 @@ #include "filelib.h" #include "tdict.h" #include "stringlib.h" +#include <cstring> typedef std::vector<WordID> Sentence; +// these "iterators" are invalidated if s is modified. note: this is allowed by std. +inline WordID const* begin(Sentence const& s) { + return &*s.begin(); +} +inline WordID const* end(Sentence const& s) { + return &*s.end(); +} +inline WordID * begin(Sentence & s) { + return &*s.begin(); +} +inline WordID * end(Sentence & s) { + return &*s.end(); +} +inline void wordcpy(WordID *dest,WordID const* src,int n) { + std::memcpy(dest,src,n*sizeof(*dest)); +} +inline void wordcpy(WordID *dest,WordID const* src,WordID const* src_end) { + wordcpy(dest,src,src_end-src); +} + + inline std::ostream & operator<<(std::ostream &out,Sentence const& s) { return out<<TD::GetString(s); } |