Skip to content

Commit

Permalink
Merge branch 'master' of github.com:kpu/kenlm
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Jul 18, 2016
2 parents 95b3786 + f365d27 commit 4501b80
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 8 additions & 1 deletion util/file_stream.hh
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ namespace util {

class FileStream : public FakeOStream<FileStream> {
public:
FileStream(int out = -1, std::size_t buffer_size = 8192)
explicit FileStream(int out = -1, std::size_t buffer_size = 8192)
: buf_(util::MallocOrThrow(std::max<std::size_t>(buffer_size, kToStringMaxBytes))),
current_(static_cast<char*>(buf_.get())),
end_(current_ + std::max<std::size_t>(buffer_size, kToStringMaxBytes)),
fd_(out) {}

#if __cplusplus >= 201103L
FileStream(FileStream &&from) noexcept : buf_(std::move(from.buf_)), current_(from.current_), end_(from.end_), fd_(from.fd_) {
from.end_ = reinterpret_cast<char*>(from.buf_.get());
from.current_ = from.end_;
}
#endif

~FileStream() {
flush();
}
Expand Down
6 changes: 6 additions & 0 deletions util/scoped.hh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,15 @@ template <class T, class Closer> class scoped_base {
protected:
T *p_;

#if __cplusplus >= 201103L
public:
scoped_base(const scoped_base &) = delete;
scoped_base &operator=(const scoped_base &) = delete;
#else
private:
scoped_base(const scoped_base &);
scoped_base &operator=(const scoped_base &);
#endif
};

template <class T, class Closer> class scoped : public scoped_base<T, Closer> {
Expand Down

0 comments on commit 4501b80

Please sign in to comment.