We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c6314d9 commit ae5ad8aCopy full SHA for ae5ad8a
moses/LVoc.h
@@ -58,7 +58,14 @@ class LVoc
58
59
void Write(const std::string& fname) const {
60
std::ofstream out(fname.c_str());
61
+ // Little-known fact: ofstream tracks failures but does not, by default,
62
+ // report them. You have to tell it to, or check for errors yourself.
63
+ out.exceptions(std::ifstream::failbit | std::ifstream::badbit);
64
Write(out);
65
+ // Make sure the file is flushed, so that any errors are reported. If we
66
+ // flush implicitly in the destructor, it won't be able to throw
67
+ // exceptions.
68
+ out.close();
69
}
70
void Write(std::ostream& out) const {
71
for(int i=data.size()-1; i>=0; --i)
0 commit comments