Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:30:29

0001 /*
0002  *             Copyright Andrey Semashev 2022.
0003  * Distributed under the Boost Software License, Version 1.0.
0004  *    (See accompanying file LICENSE_1_0.txt or copy at
0005  *          http://www.boost.org/LICENSE_1_0.txt)
0006  */
0007 /*!
0008  * \file   fclose_deleter.hpp
0009  * \author Andrey Semashev
0010  * \date   21.09.2022
0011  *
0012  * This header contains an \c fclose_deleter implementation. This is a deleter
0013  * function object that invokes <tt>std::fclose</tt> on the passed pointer to
0014  * a <tt>std::FILE</tt> structure.
0015  */
0016 
0017 #ifndef BOOST_CORE_FCLOSE_DELETER_HPP
0018 #define BOOST_CORE_FCLOSE_DELETER_HPP
0019 
0020 #include <cstdio>
0021 #include <boost/config.hpp>
0022 
0023 #ifdef BOOST_HAS_PRAGMA_ONCE
0024 #pragma once
0025 #endif
0026 
0027 namespace boost {
0028 
0029 //! A function object that closes a file
0030 struct fclose_deleter
0031 {
0032     //! Function object result type
0033     typedef void result_type;
0034     /*!
0035      * Closes the file handle
0036      */
0037     void operator() (std::FILE* p) const BOOST_NOEXCEPT
0038     {
0039         if (BOOST_LIKELY(!!p))
0040             std::fclose(p);
0041     }
0042 };
0043 
0044 } // namespace boost
0045 
0046 #endif // BOOST_CORE_FCLOSE_DELETER_HPP