Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for a snapshot of the develop branch, built from commit 0da16e0695.
PrevUpHomeNext

fclose_deleter

Header <boost/core/fclose_deleter.hpp>

Authors

  • Andrey Semashev

The header <boost/core/fclose_deleter.hpp> defines the boost::fclose_deleter function object, which can be used as a deleter with smart pointers such as unique_ptr or shared_ptr pointing to std::FILE. structures returned by std::fopen calls. The deleter calls std::fclose on the passed pointer, causing the file stream to be flushed and closed.

std::unique_ptr< std::FILE, boost::fclose_deleter > make_file(const char* filename, const char* open_mode)
{
    return { std::fopen(filename, open_mode) };
}

PrevUpHomeNext