From Jason Turner

[obj.lifetime]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp0wybuw9r/{from.md → to.md} +60 -0
tmp/tmp0wybuw9r/{from.md → to.md} RENAMED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Explicit lifetime management <a id="obj.lifetime">[[obj.lifetime]]</a>
2
+
3
+ ``` cpp
4
+ template<class T>
5
+ T* start_lifetime_as(void* p) noexcept;
6
+ template<class T>
7
+ const T* start_lifetime_as(const void* p) noexcept;
8
+ template<class T>
9
+ volatile T* start_lifetime_as(volatile void* p) noexcept;
10
+ template<class T>
11
+ const volatile T* start_lifetime_as(const volatile void* p) noexcept;
12
+ ```
13
+
14
+ *Mandates:* `T` is an implicit-lifetime type [[basic.types.general]] and
15
+ not an incomplete type [[term.incomplete.type]].
16
+
17
+ *Preconditions:* \[`p`, `(char*)p + sizeof(T)`) denotes a region of
18
+ allocated storage that is a subset of the region of storage reachable
19
+ through [[basic.compound]] `p` and suitably aligned for the type `T`.
20
+
21
+ *Effects:* Implicitly creates objects [[intro.object]] within the
22
+ denoted region consisting of an object *a* of type `T` whose address is
23
+ `p`, and objects nested within *a*, as follows: The object
24
+ representation of *a* is the contents of the storage prior to the call
25
+ to `start_lifetime_as`. The value of each created object *o* of
26
+ trivially-copyable type `U` is determined in the same manner as for a
27
+ call to `bit_cast<U>(E)` [[bit.cast]], where `E` is an lvalue of type
28
+ `U` denoting *o*, except that the storage is not accessed. The value of
29
+ any other created object is unspecified.
30
+
31
+ [*Note 1*: The unspecified value can be indeterminate. — *end note*]
32
+
33
+ *Returns:* A pointer to the *a* defined in the *Effects* paragraph.
34
+
35
+ ``` cpp
36
+ template<class T>
37
+ T* start_lifetime_as_array(void* p, size_t n) noexcept;
38
+ template<class T>
39
+ const T* start_lifetime_as_array(const void* p, size_t n) noexcept;
40
+ template<class T>
41
+ volatile T* start_lifetime_as_array(volatile void* p, size_t n) noexcept;
42
+ template<class T>
43
+ const volatile T* start_lifetime_as_array(const volatile void* p, size_t n) noexcept;
44
+ ```
45
+
46
+ *Mandates:* `T` is a complete type.
47
+
48
+ *Preconditions:* `p` is suitably aligned for an array of `T` or is null.
49
+ `n <= size_t(-1) / sizeof(T)` is `true`. If `n > 0` is `true`,
50
+ \[`(char*)p`, `(char*)p + (n * sizeof(T))`) denotes a region of
51
+ allocated storage that is a subset of the region of storage reachable
52
+ through [[basic.compound]] `p`.
53
+
54
+ *Effects:* If `n > 0` is `true`, equivalent to `start_lifetime_as<U>(p)`
55
+ where `U` is the type “array of `n` `T`”. Otherwise, there are no
56
+ effects.
57
+
58
+ *Returns:* A pointer to the first element of the created array, if any;
59
+ otherwise, a pointer that compares equal to `p` [[expr.eq]].
60
+