| 1 | /* |
| 2 | * Distributed under the Boost Software License, Version 1.0. |
| 3 | * (See accompanying file LICENSE_1_0.txt or copy at |
| 4 | * https://www.boost.org/LICENSE_1_0.txt) |
| 5 | * |
| 6 | * Copyright (c) 2024 Andrey Semashev |
| 7 | */ |
| 8 | /*! |
| 9 | * \file unallocated_resource_win_invalid_handle_value.cpp |
| 10 | * \author Andrey Semashev |
| 11 | * |
| 12 | * \brief This file tests that \c unallocated_resource supports |
| 13 | * \c INVALID_HANDLE_VALUE on Windows, as is described in the docs. |
| 14 | * |
| 15 | * This code relies on MSVC-specific behavior, which allows* \c INVALID_HANDLE_VALUE |
| 16 | * to be specified in non-type template parameters. |
| 17 | */ |
| 18 | |
| 19 | #include <boost/config.hpp> |
| 20 | |
| 21 | #if defined(BOOST_WINDOWS) && defined(BOOST_MSVC) && \ |
| 22 | !defined(BOOST_NO_CXX17_FOLD_EXPRESSIONS) && !defined(BOOST_NO_CXX17_AUTO_NONTYPE_TEMPLATE_PARAMS) |
| 23 | |
| 24 | #include <cstddef> |
| 25 | #include <windows.h> |
| 26 | #include <boost/core/functor.hpp> |
| 27 | #include <boost/scope/unique_resource.hpp> |
| 28 | |
| 29 | int main() |
| 30 | { |
| 31 | boost::scope::unique_resource< |
| 32 | HANDLE, |
| 33 | boost::core::functor< CloseHandle >, |
| 34 | boost::scope::unallocated_resource< INVALID_HANDLE_VALUE, (HANDLE)NULL > |
| 35 | > ur; |
| 36 | (void)ur; |
| 37 | |
| 38 | return 0; |
| 39 | } |
| 40 | |
| 41 | #else // defined(BOOST_WINDOWS) ... |
| 42 | |
| 43 | #include <boost/config/pragma_message.hpp> |
| 44 | |
| 45 | BOOST_PRAGMA_MESSAGE("Skipping test because it is not supported on the platform/compiler/C++ version." ) |
| 46 | |
| 47 | int main() |
| 48 | { |
| 49 | } |
| 50 | |
| 51 | #endif // defined(BOOST_WINDOWS) ... |
| 52 | |