| 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 unique_resource_bad_rtraits_isalloc_throwing.cpp |
| 10 | * \author Andrey Semashev |
| 11 | * |
| 12 | * \brief This file tests that \c unique_resource rejects resource |
| 13 | * traits where `is_allocated` is not `noexcept`. |
| 14 | */ |
| 15 | |
| 16 | #include <boost/scope/unique_resource.hpp> |
| 17 | |
| 18 | struct resource |
| 19 | { |
| 20 | resource(int) noexcept {} |
| 21 | resource& operator= (int) noexcept { return *this; }; |
| 22 | }; |
| 23 | |
| 24 | struct resource_deleter |
| 25 | { |
| 26 | using result_type = void; |
| 27 | result_type operator() (resource const&) const noexcept {} |
| 28 | }; |
| 29 | |
| 30 | struct bad_resource_traits |
| 31 | { |
| 32 | static int make_default() noexcept { return 10; } |
| 33 | static bool is_allocated(resource const& res) { return false; } |
| 34 | }; |
| 35 | |
| 36 | int main() |
| 37 | { |
| 38 | boost::scope::unique_resource< resource, resource_deleter, bad_resource_traits > ur; |
| 39 | |
| 40 | return 0; |
| 41 | } |
| 42 | |