|
|
template<class T> void* voidify( T& obj)noexcept; | (exposition only*) (constexpr since C++17) | |
Returns the address ofobj (implicitly converted tovoid*).
Contents |
obj | - | the object whose address will be taken |
&obj | (until C++11) |
std::addressof(obj) | (since C++11) |
This exposition-only function is introduced byP0896R4. It is used to describe the effects ofuninitialized memory algorithms which construct objects in uninitialized memory areas. The result pointer is used as theplacement-params of aplacementnew expression.
Initially, the return value wasconst_cast<void*>(static_cast<constvolatilevoid*>(std::addressof(obj))), which breaks const-correctness. The explicit casts were removed by the resolution ofLWG issue 3870, and the only conversion left is the implicit conversion tovoid*.
The following behavior-changing defect reports were applied retroactively to previously published C++ standards.
DR | Applied to | Behavior as published | Correct behavior |
---|---|---|---|
LWG 3870 | C++98 | the explicit casts broke const-correctness | removed these casts |
copies a range of objects to an uninitialized area of memory (function template)[edit] | |
(C++20) | copies a range of objects to an uninitialized area of memory (algorithm function object)[edit] |
copies an object to an uninitialized area of memory, defined by a range (function template)[edit] | |
(C++20) | copies an object to an uninitialized area of memory, defined by a range (algorithm function object)[edit] |
(C++17) | moves a range of objects to an uninitialized area of memory (function template)[edit] |
(C++20) | moves a range of objects to an uninitialized area of memory (algorithm function object)[edit] |
constructs objects bydefault-initialization in an uninitialized area of memory, defined by a range (function template)[edit] | |
constructs objects bydefault-initialization in an uninitialized area of memory, defined by a range (algorithm function object)[edit] | |
constructs objects byvalue-initialization in an uninitialized area of memory, defined by a range (function template)[edit] | |
constructs objects byvalue-initialization in an uninitialized area of memory, defined by a range (algorithm function object)[edit] | |
(C++20) | creates an object at a given address (function template)[edit] |
(C++20) | creates an object at a given address (algorithm function object)[edit] |