问题
Is there an available combination of std::ios::openmode
to avoid modifications of an existing file and allow only the creation of a new one ?
回答1:
No there isn't. See the C++03 Standard § 27.4.2.1.4/1, or the C++11 Standard § 27.5.3.1.4/1
if to hand or otherwise http://en.cppreference.com/w/cpp/io/ios_base/openmode. As none
of the specified constants that may be |-conjoined to form an openmode
implies that the opened file shall not exist no conjunction of them can have
that implication.
来源:https://stackoverflow.com/questions/16611977/combination-of-stdiosopenmode-to-avoid-modifications-of-an-existing-file