Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 08:44:21

0001 /*
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * https://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * Copyright (c) 2023 Andrey Semashev
0007  */
0008 /*!
0009  * \file scope/fd_resource_traits.hpp
0010  *
0011  * This header contains definition of \c unique_resource traits
0012  * for compatibility with POSIX-like file descriptors.
0013  */
0014 
0015 #ifndef BOOST_SCOPE_FD_RESOURCE_TRAITS_HPP_INCLUDED_
0016 #define BOOST_SCOPE_FD_RESOURCE_TRAITS_HPP_INCLUDED_
0017 
0018 #include <boost/scope/detail/config.hpp>
0019 #include <boost/scope/detail/header.hpp>
0020 
0021 #ifdef BOOST_HAS_PRAGMA_ONCE
0022 #pragma once
0023 #endif
0024 
0025 namespace boost {
0026 namespace scope {
0027 
0028 //! POSIX-like file descriptor resource traits
0029 struct fd_resource_traits
0030 {
0031     //! Creates a default fd value
0032     static int make_default() noexcept
0033     {
0034         return -1;
0035     }
0036 
0037     //! Tests if the fd is allocated (valid)
0038     static bool is_allocated(int fd) noexcept
0039     {
0040         return fd >= 0;
0041     }
0042 };
0043 
0044 } // namespace scope
0045 } // namespace boost
0046 
0047 #include <boost/scope/detail/footer.hpp>
0048 
0049 #endif // BOOST_SCOPE_FD_RESOURCE_TRAITS_HPP_INCLUDED_