Warning, file /include/boost/json/static_resource.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_JSON_STATIC_RESOURCE_HPP
0011 #define BOOST_JSON_STATIC_RESOURCE_HPP
0012
0013 #include <boost/container/pmr/memory_resource.hpp>
0014 #include <boost/json/detail/config.hpp>
0015 #include <boost/json/is_deallocate_trivial.hpp>
0016 #include <cstddef>
0017
0018 namespace boost {
0019 namespace json {
0020
0021 #ifdef _MSC_VER
0022 #pragma warning(push)
0023 #pragma warning(disable: 4275)
0024 #endif
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067 class
0068 BOOST_JSON_DECL
0069 BOOST_SYMBOL_VISIBLE
0070 static_resource final
0071 : public container::pmr::memory_resource
0072 {
0073 void* p_;
0074 std::size_t n_;
0075 std::size_t size_;
0076
0077 public:
0078
0079 static_resource(
0080 static_resource const&) = delete;
0081
0082
0083 static_resource& operator=(
0084 static_resource const&) = delete;
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108 static_resource(
0109 unsigned char* buffer,
0110 std::size_t size) noexcept;
0111
0112 #if defined(__cpp_lib_byte) || defined(BOOST_JSON_DOCS)
0113 static_resource(
0114 std::byte* buffer,
0115 std::size_t size) noexcept
0116 : static_resource(reinterpret_cast<
0117 unsigned char*>(buffer), size)
0118 {
0119 }
0120 #endif
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142 template<std::size_t N>
0143 explicit
0144 static_resource(
0145 unsigned char(&buffer)[N]) noexcept
0146 : static_resource(&buffer[0], N)
0147 {
0148 }
0149
0150 #if defined(__cpp_lib_byte) || defined(BOOST_JSON_DOCS)
0151 template<std::size_t N>
0152 explicit
0153 static_resource(
0154 std::byte(&buffer)[N]) noexcept
0155 : static_resource(&buffer[0], N)
0156 {
0157 }
0158 #endif
0159
0160
0161 #ifndef BOOST_JSON_DOCS
0162
0163 template<std::size_t N>
0164 static_resource(
0165 unsigned char(&buffer)[N], std::size_t n) noexcept
0166 : static_resource(&buffer[0], n)
0167 {
0168
0169
0170
0171 BOOST_ASSERT(n <= N);
0172 }
0173
0174 #ifdef __cpp_lib_byte
0175
0176 template<std::size_t N>
0177 static_resource(
0178 std::byte(&buffer)[N], std::size_t n) noexcept
0179 : static_resource(&buffer[0], n)
0180 {
0181
0182
0183
0184 BOOST_ASSERT(n <= N);
0185 }
0186 #endif
0187 #endif
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201 void
0202 release() noexcept;
0203
0204 protected:
0205 #ifndef BOOST_JSON_DOCS
0206 void*
0207 do_allocate(
0208 std::size_t n,
0209 std::size_t align) override;
0210
0211 void
0212 do_deallocate(
0213 void* p,
0214 std::size_t n,
0215 std::size_t align) override;
0216
0217 bool
0218 do_is_equal(
0219 memory_resource const& mr
0220 ) const noexcept override;
0221 #endif
0222 };
0223
0224 #ifdef _MSC_VER
0225 #pragma warning(pop)
0226 #endif
0227
0228 template<>
0229 struct is_deallocate_trivial<
0230 static_resource>
0231 {
0232 static constexpr bool value = true;
0233 };
0234
0235 }
0236 }
0237
0238 #endif