voidify
From cppreference.com
C++
Feature test macros (C++20)
Concepts library (C++20)
Metaprogramming library (C++11)
Ranges library (C++20)
Filesystem library (C++17)
Concurrency support library (C++11)
Execution control library (C++26)
Memory management library
Uninitialized memory algorithms
Constrained uninitialized memory algorithms
Memory resources
Uninitialized storage (until C++20)
Garbage collector support (until C++23)
voidify
(exposition only*)
(C++11)
(C++23)
(C++11)
(C++17)
(C++11)
(C++11)
(C++20)
(C++20)
(C++17)
(C++11)
(C++17)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(C++17)
(until C++20*)
(until C++20*)
(until C++20*)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)(until C++23)
(C++11)
(C++11)
(C++17)
(C++20)
(C++17)
(C++11)
(C++11)
(C++11)
(until C++17*)
(C++11)
(C++17)
(C++26)
(C++26)
(C++11)
(C++11)
(C++11)
(C++23)
(C++23)
(C++11)
(C++20)
(C++11)
(C++11)
(C++20)
(C++26)
template< class T >
void* voidify( T& obj ) noexcept;
(exposition only*) void* voidify( T& obj ) noexcept;
(constexpr since C++17)
Returns the address of obj (implicitly converted to void*).
[edit] Parameters
obj
-
the object whose address will be taken
[edit] Return value
&obj
(until C++11)std::addressof (obj)
(since C++11)[edit] Notes
This exposition-only function is introduced by P0896R4. It is used to describe the effects of uninitialized memory algorithms which construct objects in uninitialized memory areas. The result pointer is used as the placement-params of a placement new expression.
Initially, the return value was const_cast<void*>(static_cast<const volatile void*>(std::addressof (obj))), which breaks const-correctness. The explicit casts were removed by the resolution of LWG issue 3870, and the only conversion left is the implicit conversion to void*.
[edit] Defect reports
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 |
[edit] See also
(C++20)
(algorithm function object)[edit]
(C++20)
(algorithm function object)[edit]
(C++20)
(algorithm function object)[edit]
(C++17)
(function template) [edit]
constructs objects by default-initialization in an uninitialized area of memory, defined by a range
(algorithm function object)[edit]
(algorithm function object)[edit]
(C++17)
(function template) [edit]
constructs objects by value-initialization in an uninitialized area of memory, defined by a range
(algorithm function object)[edit]
(algorithm function object)[edit]