Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / outcome / doc / src / content / faq / _index.md
1 +++
2 title = "Frequently asked questions"
3 weight = 30
4 +++
5
6 {{% toc %}}
7
8 ## Is Outcome safe to use in extern APIs?
9
10 Outcome is specifically designed for use in the public interfaces of multi-million
11 line codebases. `result`'s layout is hard coded to:
12
13 ```c
14 struct
15 {
16   T value;
17   unsigned int flags;
18   EC error;
19 };
20 ```
21
22 This is C-compatible if `T` and `EC` are C-compatible. {{% api "std::error_code" %}}
23 is *probably* C-compatible, but its layout is not standardised (though there is a
24 normative note in the standard about its layout). Hence Outcome cannot provide a
25 C macro API for standard Outcome, but we can for [Experimental Outcome]({{< relref "/experimental/c-api" >}}).
26
27
28 ## Does Outcome implement over-alignment?
29
30 Variant-based alternatives to Outcome such as {{% api "std::expected<T, E>" %}}
31 would use `std::aligned_union` to ensure appropriate over-alignment for the storage of
32 either a `T` or an `E`. This discovers the over-alignment for a type using
33 `std::alignment_of`, which is defaulted to `alignof()`.
34
35 Outcome uses `struct`-based storage, as described above. Any over-alignment of
36 `result` or `outcome` will follow the ordinary alignment and padding rules for
37 `struct` on your compiler. Traits such as `std::alignment_of`, or other standard
38 library facilities, are not used.
39
40
41 ## Does Outcome implement the no-fail, strong or basic exception guarantee?
42
43 ([You can read about the meaning of these guarantees at cppreference.com](https://en.cppreference.com/w/cpp/language/exceptions#Exception_safety))
44
45 If for the following operations:
46
47 - Construction
48 - Assignment
49 - Swap
50
51 ... the corresponding operation in **all** of `value_type`, `error_type` (and
52 `exception_type` for `outcome`) is `noexcept(true)`, then `result` and
53 `outcome`'s operation is `noexcept(true)`. This propagates the no-fail exception
54 guarantee of the underlying types. Otherwise the basic guarantee applies for all
55 but Swap, under the same rules as for the `struct` layout type given above e.g.
56 value would be constructed first, then the flags, then the error. If the error
57 throws, value and status bits would be as if the failure had not occurred, same
58 as for aborting the construction of any `struct` type.
59
60 It is recognised that these weak guarantees may be unsuitable for some people,
61 so Outcome implements `swap()` with much stronger guarantees, as one can locally refine,
62 without too much work, one's own custom classes from `result` and `outcome` implementing
63 stronger guarantees for construction and assignment using `swap()` as the primitive
64 building block.
65
66 The core ADL discovered implementation of strong guarantee swap is {{% api "strong_swap(bool &all_good, T &a, T &b)" %}}.
67 This can be overloaded by third party code with custom strong guarantee swap
68 implementations, same as for `std::swap()`. Because strong guarantee swap may fail
69 when trying to restore input state during handling of failure to swap, the
70 `all_good` boolean becomes false if restoration fails, at which point both
71 results/outcomes get marked as tainted via {{% api "has_lost_consistency()" %}}.
72
73 It is **up to you** to check this flag to see if known good state has been lost,
74 as Outcome never does so on your behalf. The simple solution to avoiding having
75 to deal with this situation is to always choose your value, error and exception
76 types to have non-throwing move constructors and move assignments. This causes
77 the strong swap implementation to no longer be used, as it is no longer required,
78 and standard swap is used instead.
79
80
81 ## Does Outcome have a stable ABI and API?
82
83 Right now, no. Though the data layout shown above is not expected to change.
84
85 Outcome's ABI and API will be formally fixed as **the** v2 interface approximately
86 one year after its first Boost release. Thereafter the
87 [ABI compliance checker](https://lvc.github.io/abi-compliance-checker/)
88 will be run per-commit to ensure Outcome's ABI and API remains stable.
89
90 Note that the stable ABI and API guarantee will only apply to standalone
91 Outcome, not to Boost.Outcome. Boost.Outcome has dependencies on other
92 parts of Boost which are not stable across releases.
93
94 Note also that the types you configure a `result` or `outcome` with also need
95 to be ABI stable if `result` or `outcome` is to be ABI stable.
96
97
98 ## Can I use `result<T, EC>` across DLL/shared object boundaries?
99
100 A known problem with using DLLs (and to smaller extent shared libraries) is that global
101 objects may get duplicated: one instance in the executable and one in the DLL. This
102 behaviour is not incorrect according to the C++ Standard, as the Standard does not
103 recognize the existence of DLLs or shared libraries. Therefore, program designs that
104 depend on globals having unique addresses may become compromised when used in a program
105 using DLLs.
106
107 Nothing in Outcome depends on the addresses of globals, plus the guaranteed fixed data
108 layout (see answer above) means that different versions of Outcome can be used in
109 different DLLs, and it probably will work okay (it is still not advised that you do that
110 as that is an ODR violation).
111 However, one of the most likely candidate for `EC` -- `std::error_code` -- does depend
112 on the addresses of globals for correct functioning.
113
114 The standard library is required to implement globally unique addresses for the standard library
115 provided {{% api "std::error_category" %}} implementations e.g. `std::system_category()`.
116 User defined error code categories may **not** have unique global addresses, and thus
117 introduce misoperation.
118
119 `boost::system::error_code`, since version 1.69 does offer an *opt-in* guarantee
120 that it does not depend on the addresses of globals **if** the user defined error code
121 category *opts-in* to the 64-bit comparison mechanism. This can be seen in the specification of
122 `error_category::operator==` in
123 [Boost.System synopsis](https://www.boost.org/doc/libs/1_69_0/libs/system/doc/html/system.html#ref_synopsis).
124
125 Alternatively, the `status_code` in [Experimental Outcome](({{< relref "/experimental/differences" >}})),
126 due to its more modern design, does not suffer from any problems from being used in shared
127 libraries in any configuration.
128
129
130 ## Why two types `result<>`  and `outcome<>`, rather than just one?
131
132 `result` is the simple, success OR failure type.
133
134 `outcome` extends `result` with a third state to transport, conventionally (but not necessarily) some sort of "abort" or "exceptional" state which a function can return to indicate that not only did the operation fail, but it did so *catastrophically* i.e. please abort any attempt to retry the operation.
135
136 A perfect alternative to using `outcome` is to throw a C++ exception for the abort code path, and indeed most programs ought to do exactly that instead of using `outcome`. However there are a number of use cases where choosing `outcome` shines:
137
138 1. Where C++ exceptions or RTTI is not available, but the ability to fail catastrophically without terminating the program is important.
139 2. Where deterministic behaviour is required even in the catastrophic failure situation.
140 3. In unit test suites of code using Outcome it is extremely convenient to accumulate test failures into an `outcome` for later reporting. A similar convenience applies to RPC situations, where C++ exception throws need to be accumulated for reporting back to the initiating endpoint.
141 4. Where a function is "dual use deterministic" i.e. it can be used deterministically, in which case one switches control flow based on `.error()`, or it can be used non-deterministically by throwing an exception perhaps carrying a custom payload.
142
143
144 ## How badly will including Outcome in my public interface affect compile times?
145
146 The quick answer is that it depends on how much convenience you want.
147
148 The convenience header `<result.hpp>` is dependent on `<system_error>` or Boost.System, which unfortunately includes `<string>` and thus
149 drags in quite a lot of other slow-to-parse stuff. If your public interface already includes `<string>`,
150 then the impact of additionally including Outcome will be low. If you do not include `<string>`,
151 unfortunately impact may be relatively quite high, depending on the total impact of your
152 public interface files.
153
154 If you've been extremely careful to avoid ever including the most of the STL headers
155 into your interfaces in order to maximise build performance, then `<basic_result.hpp>`
156 can have as few dependencies as:
157
158 1. `<cstdint>`
159 2. `<initializer_list>`
160 3. `<iosfwd>`
161 4. `<new>`
162 5. `<type_traits>`
163 6. `<cstdio>`
164 7. `<cstdlib>`
165 8. `<cassert>`
166
167 These, apart from `<iosfwd>`, tend to be very low build time impact in most standard
168 library implementations. If you include only `<basic_result.hpp>`, and manually configure
169 `basic_result<>` by hand, compile time impact will be minimised.
170
171 (See reference documentation for {{% api "basic_result<T, E, NoValuePolicy>" %}} for more detail.
172
173
174 ## Is Outcome suitable for fixed latency/predictable execution coding such as for high frequency trading or audio?
175
176 Great care has been taken to ensure that Outcome never unexpectedly executes anything
177 with unbounded execution times such as `malloc()`, `dynamic_cast<>()` or `throw`.
178 Outcome works perfectly with C++ exceptions and RTTI globally disabled.
179
180 Outcome's entire design premise is that its users are happy to exchange a small, predictable constant overhead
181 during successful code paths, in exchange for predictable failure code paths.
182
183 In contrast, table-based exception handling gives zero run time overhead for the
184 successful code path, and completely unpredictable (and very expensive) overhead
185 for failure code paths.
186
187 For code where predictability of execution, no matter the code path, is paramount,
188 writing all your code to use Outcome is not a bad place to start. Obviously enough,
189 do choose a non-throwing policy when configuring `outcome` or `result` such as
190 {{% api "all_narrow" %}} to guarantee that exceptions can never be thrown by Outcome
191 (or use the convenience typedef for `result`, {{% api "unchecked<T, E = varies>" %}} which uses `policy::all_narrow`).
192
193
194 ## What kind of runtime performance impact will using Outcome in my code introduce?
195
196 It is very hard to say anything definitive about performance impacts in codebases one
197 has never seen. Each codebase is unique. However to come up with some form of measure,
198 we timed traversing ten stack frames via each of the main mechanisms, including the
199 "do nothing" (null) case.
200
201 A stack frame is defined to be something called by the compiler whilst
202 unwinding the stack between the point of return in the ultimate callee and the base
203 caller, so for example ten stack allocated objects might be destructed, or ten levels
204 of stack depth might be unwound. This is not a particularly realistic test, but it
205 should at least give one an idea of the performance impact of returning Outcome's
206 `result` or `outcome` over say returning a plain integer, or throwing an exception.
207
208 ### High end CPU: Intel Skylake x64
209
210 This is a high end CPU with very significant ability to cache, predict, parallelise
211 and execute out-of-order such that tight, repeated loops perform very well. It has
212 a large μop cache able to wholly contain the test loop, meaning that these results
213 are a **best case** performance.
214
215 {{% figure src="/faq/results_skylake_log.png" title="Log graph comparing GCC 7.4, clang 8.0 and Visual Studio 2017.9 on x64, for exceptions-globally-disabled, ordinary and link-time-optimised build configurations." %}}
216
217 As you can see, throwing and catching an exception is
218 expensive on table-based exception handling implementations such as these, anywhere
219 between 26,000 and 43,000 CPU cycles. And this is the *hot path* situation, this
220 benchmark is a loop around hot cached code. If the tables are paged out onto storage,
221 you are talking about **millions** of CPU cycles.
222
223 Simple integer returns (i.e. do nothing null case)
224 are always going to be the fastest as they do the least work, and that costs 80 to 90
225 CPU cycles on this Intel Skylake CPU.
226
227 Note that returning a `result<int, std::error_code>` with a "success (error code)"
228 is no more than 5% added runtime overhead over returning a naked int on GCC and clang. On MSVC
229 it costs an extra 20% or so, mainly due to poor code optimisation in the VS2017.9 compiler. Note that "success
230 (experimental status code)" optimises much better, and has almost no overhead over a
231 naked int.
232
233 Returning a `result<int, std::error_code>` with a "failure (error code)"
234 is less than 5% runtime overhead over returning a success on GCC, clang and MSVC.
235
236 You might wonder what happens if type `E` has a non-trivial destructor, thus making the
237 `result<T, E>` have a non-trivial destructor? We tested `E = std::exception_ptr` and
238 found less than a 5% overhead to `E = std::error_code` for returning success. Returning a failure
239 was obviously much slower at anywhere between 300 and 1,100 CPU cycles, due to the
240 dynamic memory allocation and free of the exception ptr, plus at least two atomic operations per stack frame, but that is
241 still two orders of magnitude better than throwing and catching an exception.
242
243 We conclude that if failure is anything but extremely rare in your C++ codebase,
244 using Outcome instead of throwing and catching exceptions ought to be quicker overall:
245
246 - Experimental Outcome is statistically indistinguishable from the null case on this
247 high end CPU, for both returning success and failure, on all compilers.
248 - Standard Outcome is less than 5%
249 worse than the null case for returning successes on GCC and clang, and less than 10% worse than
250 the null case for returning failures on GCC and clang.
251 - Standard Outcome optimises
252 poorly on VS2017.9, indeed markedly worse than on previous point releases, so let's
253 hope that Microsoft fix that soon. It currently has a less than 20% overhead on the null case.
254
255 ### Mid tier CPU: ARM Cortex A72
256
257 This is a four year old mid tier CPU used in many high end mobile phones and tablets
258 of its day, with good ability to cache, predict, parallelise
259 and execute out-of-order such that tight, repeated loops perform very well. It has
260 a μop cache able to wholly contain the test loop, meaning that these results
261 are a **best case** performance.
262
263 {{% figure src="/faq/results_arm_a72_log.png" title="Log graph comparing GCC 7.3 and clang 7.3 on ARM64, for exceptions-globally-disabled, ordinary and link-time-optimised build configurations." %}}
264
265 This ARM chip is a very consistent performer -- null case, success, or failure, all take
266 almost exactly the same CPU cycles. Choosing Outcome, in any configuration, makes no
267 difference to not using Outcome at all. Throwing and catching a C++ exception costs
268 about 90,000 CPU cycles, whereas the null case/Outcome costs about 130 - 140 CPU cycles.
269
270 There is very little to say about this CPU, other than Outcome is zero overhead on it. The same
271 applied to the ARM Cortex A15 incidentally, which I test cased extensively when
272 deciding on the Outcome v2 design back after the first peer review. The v2 design
273 was chosen partially because of such consistent performance on ARM.
274
275 ### Low end CPUs: Intel Silvermont x64 and ARM Cortex A53
276
277 These are low end CPUs with a mostly or wholly in-order execution core. They have a small
278 or no μop cache, meaning that the CPU must always decode the instruction stream.
279 These results represent an execution environment more typical of CPUs two decades
280 ago, back when table-based EH created a big performance win if you never threw
281 an exception.
282
283 {{% figure src="/faq/results_silvermont_log.png" title="Log graph comparing GCC 7.3 and clang 7.3 on x64, for exceptions-globally-disabled, ordinary and link-time-optimised build configurations." %}}
284 {{% figure src="/faq/results_arm_a53_log.png" title="Log graph comparing GCC 7.3 and clang 7.3 on ARM64, for exceptions-globally-disabled, ordinary and link-time-optimised build configurations." %}}
285
286 The first thing to mention is that clang generates very high performance code for
287 in-order cores, far better than GCC. It is said that this is due to a very large investment by
288 Apple in clang/LLVM for their devices sustained over many years. In any case, if you're
289 targeting in-order CPUs, don't use GCC if you can use clang instead!
290
291 For the null case, Silvermont and Cortex A53 are quite similar in terms of CPU clock cycles. Ditto
292 for throwing and catching a C++ exception (approx 150,000 CPU cycles). However the Cortex
293 A53 does far better with Outcome than Silvermont, a 15% versus 100% overhead for Standard
294 Outcome, and a 4% versus 20% overhead for Experimental Outcome.
295
296 Much of this large difference is in fact due to calling convention differences. x64 permits up to 8 bytes
297 to be returned from functions by CPU register. `result<int>` consumes 24 bytes, so on x64
298 the compiler writes the return value to the stack. However ARM64 permits up to 64 bytes
299 to be returned in registers, so `result<int>` is returned via CPU registers on ARM64.
300
301 On higher end CPUs, memory is read and written in cache lines (32 or 64 bytes), and
302 reads and writes are coalesced and batched together by the out-of-order execution core. On these
303 low end CPUs, memory is read and written sequentially per assembler instruction,
304 so only one load or one store to L1
305 cache can occur at a time. This makes writing the stack particularly slow on in-order
306 CPUs. Memory operations which "disappear" on higher end CPUs take considerable time
307 on low end CPUs. This particularly punishes Silvermont in a way which does not punish
308 the Cortex A53, because of having to write multiple values to the stack to create the
309 24 byte object to be returned.
310
311 The conclusion to take away from this is that if you are targeting a low end CPU,
312 table-based EH still delivers significant performance improvements for the success
313 code path. Unless determinism in failure is critically important, you should not
314 use Outcome on in-order execution CPUs.
315
316
317 ## Why is implicit default construction disabled?
318
319 This was one of the more interesting points of discussion during the peer review of
320 Outcome v1. v1 had a formal empty state. This came with many advantages, but it
321 was not felt to be STL idiomatic as `std::optional<result<T>>` is what was meant, so
322 v2 has eliminated any legal possibility of being empty.
323
324 The `expected<T, E>` proposal of that time (May 2017) did permit default construction
325 if its `T` type allowed default construction. This was specifically done to make
326 `expected<T, E>` more useful in STL containers as one can say resize a vector without
327 having to supply an `expected<T, E>` instance to fill the new items with. However
328 there was some unease with that design choice, because it may cause programmers to
329 use some type `T` whose default constructed state is overloaded with additional meaning,
330 typically "to be filled" i.e. a de facto empty state via choosing a magic value.
331
332 For the v2 redesign, the various arguments during the v1 review were considered.
333 Unlike `expected<T, E>` which is intended to be a general purpose Either monad
334 vocabulary type, Outcome's types are meant primarily for returning success or failure
335 from functions. The API should therefore encourage the programmer to not overload
336 the successful type with additional meaning of "to be filled" e.g. `result<std::optional<T>>`.
337 The decision was therefore taken to disable *implicit* default construction, but
338 still permit *explicit* default construction by making the programmer spell out their
339 intention with extra typing.
340
341 To therefore explicitly default construct a `result<T>` or `outcome<T>`, use one
342 of these forms as is the most appropriate for the use case:
343
344 1. Construct with just `in_place_type<T>` e.g. `result<T>(in_place_type<T>)`.
345 2. Construct via `success()` e.g. `outcome<T>(success())`.
346 3. Construct from a `void` form e.g. `result<T>(result<void>(in_place_type<void>))`.
347
348
349 ## How far away from the proposed `std::expected<T, E>` is Outcome's `checked<T, E>`?
350
351 Not far, in fact after the first Boost.Outcome peer review in May 2017, Expected moved
352 much closer to Outcome, and Outcome deliberately provides {{% api "checked<T, E = varies>" %}}
353 as a semantic equivalent.
354
355 Here are the remaining differences which represent the
356 divergence of consensus opinion between the Boost peer review and WG21 on the proper
357 design for this object:
358
359 1. `checked<T, E>` has no default constructor. Expected has a default constructor if
360 `T` has a default constructor.
361 2. `checked<T, E>` uses the same constructor design as `std::variant<...>`. Expected
362 uses the constructor design of `std::optional<T>`.
363 3. `checked<T, E>` cannot be modified after construction except by assignment.
364 Expected provides an `.emplace()` modifier.
365 4. `checked<T, E>` permits implicit construction from both `T` and `E` when
366 unambiguous. Expected permits implicit construction from `T` alone.
367 5. `checked<T, E>` does not permit `T` and `E` to be the same, and becomes annoying
368 to use if they are constructible into one another (implicit construction self-disables).
369 Expected permits `T` and `E` to be the same.
370 6. `checked<T, E>` throws `bad_result_access_with<E>` instead of Expected's
371 `bad_expected_access<E>`.
372 7. `checked<T, E>` models `std::variant<...>`. Expected models `std::optional<T>`. Thus:
373    - `checked<T, E>` does not provide `operator*()` nor `operator->`
374    - `checked<T, E>` `.error()` is wide (i.e. throws on no-value) like `.value()`.
375    Expected's `.error()` is narrow (UB on no-error). [`checked<T, E>` provides
376    `.assume_value()` and `.assume_error()` for narrow (UB causing) observers].
377 8. `checked<T, E>` uses `success<T>` and `failure<E>` type sugars for disambiguation.
378 Expected uses `unexpected<E>` only.
379 9. `checked<T, E>` requires `E` to be default constructible.
380 10. `checked<T, E>` defaults `E` to `std::error_code` or `boost::system::error_code`.
381 Expected does not default `E`.
382
383 In fact, the two are sufficiently close in design that a highly conforming `expected<T, E>`
384 can be implemented by wrapping up `checked<T, E>` with the differing functionality:
385
386 {{% snippet "expected_implementation.cpp" "expected_implementation" %}}
387
388
389 ## Why doesn't Outcome duplicate `std::expected<T, E>`'s design?
390
391 There are a number of reasons:
392
393 1. Outcome is not aimed at the same audience as Expected. We target developers
394 and users who would be happy to use Boost. Expected targets the standard library user.
395
396 2. Outcome believes that the monadic use case isn't as important as Expected does.
397 Specifically, we think that 99% of use of Expected in the real world will be to
398 return failure from functions, and not as some sort of enhanced or "rich" Optional.
399 Outcome therefore models a subset of Variant, whereas Expected models an extended Optional.
400
401 3. Outcome believes that if you are thinking about using something like Outcome,
402 then for you writing failure code will be in the same proportion as writing success code,
403 and thus in Outcome writing for failure is exactly the same as writing for success.
404 Expected assumes that success will be more common than failure, and makes you type
405 more when writing for failure.
406
407 4. Outcome goes to considerable effort to help the end user type fewer characters
408 during use. This results in tighter, less verbose, more succinct code. The cost of this is a steeper
409 learning curve and more complex mental model than when programming with Expected.
410
411 5. Outcome has facilities to make easier interoperation between multiple third
412 party libraries each using incommensurate Outcome (or Expected) configurations. Expected does
413 not do any of this, but subsequent WG21 papers do propose various interoperation
414 mechanisms, [one of which](https://wg21.link/P0786) Outcome implements so code using Expected will seamlessly
415 interoperate with code using Outcome.
416
417
418 ## Is Outcome riddled with undefined behaviour for const, const-containing and reference-containing types?
419
420 The short answer is not any more in C++ 20 and after, thanks to changes made to
421 C++ 20 at the Belfast WG21 meeting in November 2019.
422
423 The longer answer is that before C++ 20, use of placement
424 new on types containing `const` member types where the resulting pointer was
425 thrown away is undefined behaviour. As of the resolution of a national body
426 comment, this is no longer the case, and now Outcome is free of this particular
427 UB for C++ 20 onwards.
428
429 This still affects C++ before 20, though no major compiler is affected. Still,
430 if you wish to avoid UB, don't use `const` types within Outcome types (or any
431 `optional<T>`, or `vector<T>` or any STL container type for that matter).
432
433 ### More detail
434
435 Before the C++ 14 standard, placement new into storage which used to contain
436 a const type was straight out always undefined behaviour, period. Thus all use of
437 placement new within a `result<const_containing_type>`, or indeed an `optional<const_containing_type>`, is always
438 undefined behaviour before C++ 14. From `[basic.life]` for the C++ 11 standard:
439
440 > Creating a new object at the storage location that a const object with static, 
441 > thread, or automatic storage duration occupies or, at the storage location
442 > that such a const object used to occupy before its lifetime ended results
443 > in undefined behavior. 
444
445 This being excessively restrictive, from C++ 14 onwards, `[basic_life]` now states:
446
447 > If, after the lifetime of an object has ended and before the storage which
448 > the object occupied is reused or released, a new object is created at the
449 > storage location which the original object occupied, a pointer that
450 > pointed to the original object, a reference that referred to the original
451 > object, or the name of the original object will automatically refer to the
452 > new object and, once the lifetime of the new object has started, can be
453 > used to manipulate the new object, if:
454 >
455 >   — the storage for the new object exactly overlays the storage location which
456 >     the original object occupied, and
457 >
458 >   — the new object is of the same type as the original object (ignoring the
459 >     top-level cv-qualifiers), and
460 >
461 >   — the type of the original object is not const-qualified, and, if a class type,
462 >     does not contain any non-static data member whose type is const-qualified
463 >     or a reference type, and
464 >
465 >   — neither the original object nor the new object is a potentially-overlapping
466 >     subobject
467
468 Leaving aside my personal objections to giving placement new of non-const
469 non-reference types magical pointer renaming powers, the upshot is that if
470 you want defined behaviour for placement new of types containing const types
471 or references, you must store the pointer returned by placement new, and use
472 that pointer for all further reference to the newly created object. This
473 obviously adds eight bytes of storage to a `result<const_containing_type>`, which is highly
474 undesirable given all the care and attention paid to keeping it small. The alternative
475 is to use {{% api "std::launder" %}}, which was added in C++ 17, to 'launder'
476 the storage into which we placement new before each and every use of that
477 storage. This forces the compiler to reload the object stored by placement
478 new on every occasion, and not assume it can be constant propagated, which
479 impacts codegen quality.
480
481 As mentioned above, this issue (in so far as it applies to types containing
482 user supplied `T` which might be `const`) has been resolved as of C++ 20 onwards,
483 and it is extremely unlikely that any C++ compiler will act on any UB here in
484 C++ 17 or 14 given how much of STL containers would break.