std::ios_base::openmode

Specifies available file open flags. It is a BitmaskType, the following constants are defined:

# Declarations

typedef /* implementation defined */ openmode;
static constexpr openmode app = /* implementation defined */;
static constexpr openmode binary = /* implementation defined */;
static constexpr openmode in = /* implementation defined */;
static constexpr openmode out = /* implementation defined */;
static constexpr openmode trunc = /* implementation defined */;
static constexpr openmode ate = /* implementation defined */;
static constexpr openmode noreplace = /* implementation defined */;

(since C++23)

# Example

#include <fstream>
#include <iostream>
#include <string>
 
int main()
{
    const char* fname = "unique_name.txt";
 
    // write to a temporary stream object
    std::fstream(fname, std::ios::out | std::ios::trunc) << "Hi";
 
    std::string s;
    std::fstream(fname, std::ios::in) >> s;
    std::cout << s << '\n';
}

# See also