Not. Note that mkstemp not part of C (C99, at least) or the C ++ standard - it is a POSIX add-on. C ++ only has tmpfile and tmpnam in the library part of C.
Boost.IOStreams , however, provides a file_descriptor device class that can be used to create a thread that works on what mkstemp returns.
If I remember correctly, it should look like this:
namespace io = boost::iostreams; int fd = mkstemp("foo"); if (fd == -1) throw something; io::file_descriptor device(fd); io::stream<io::file_descriptor> stream(device); stream << 42;
Cat plus plus
source share