![]() |
|
|||
File indexing completed on 2025-04-26 08:37:10
0001 // 0002 // Copyright (c) 2024 Dmitry Arkhipov (grisumbras@yandex.ru) 0003 // 0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying 0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 0006 // 0007 // Official repository: https://github.com/boostorg/json 0008 // 0009 0010 #ifndef BOOST_JSON_IS_DEALLOCATE_TRIVIAL_HPP 0011 #define BOOST_JSON_IS_DEALLOCATE_TRIVIAL_HPP 0012 0013 namespace boost { 0014 namespace json { 0015 0016 /** Return true if a memory resource's deallocate function has no effect. 0017 0018 This metafunction may be specialized to indicate to the library that calls 0019 to the `deallocate` function of a `boost::container::pmr::memory_resource` 0020 have no effect. The implementation will elide such calls when it is safe to 0021 do so. By default, the implementation assumes that all memory resources 0022 require a call to `deallocate` for each memory region obtained by 0023 calling `allocate`. 0024 0025 @par Example 0026 0027 This example specializes the metafuction for `my_resource`, 0028 to indicate that calls to deallocate have no effect: 0029 0030 @code 0031 0032 // Forward-declaration for a user-defined memory resource 0033 struct my_resource; 0034 0035 // It is necessary to specialize the template from 0036 // inside the namespace in which it is declared: 0037 0038 namespace boost { 0039 namespace json { 0040 0041 template<> 0042 struct is_deallocate_trivial< my_resource > 0043 { 0044 static constexpr bool value = true; 0045 }; 0046 0047 } // namespace json 0048 } // namespace boost 0049 0050 @endcode 0051 0052 It is usually not necessary for users to check this trait. 0053 Instead, they can call @ref storage_ptr::is_deallocate_trivial 0054 to determine if the pointed-to memory resource has a trivial 0055 deallocate function. 0056 0057 @see 0058 @ref storage_ptr, 0059 @ref boost::container::pmr::memory_resource 0060 */ 0061 template<class T> 0062 struct is_deallocate_trivial 0063 { 0064 /** A bool equal to true if calls to `T::do_deallocate` have no effect. 0065 0066 The primary template sets `value` to false. 0067 */ 0068 static constexpr bool value = false; 0069 }; 0070 0071 } // namespace json 0072 } // namespace boost 0073 0074 #endif // BOOST_JSON_IS_DEALLOCATE_TRIVIAL_HPP
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |