Skip to content

Search topics & cppreference

Search all study topics, concept maps, and 6,587 C++ and C reference pages.

voidify

Returns the address of obj (implicitly converted to void*).

Memory management
  • C++11
  • C++17
  • C++20
1 min readView on cppreference
NotebookLM
template< class T >
void* voidify( T& obj ) noexcept;
(exposition only*)
(constexpr since C++17)

Returns the address of obj (implicitly converted to void*).

Parameters

obj - the object whose address will be taken

Return value

&obj

(until C++11)

std::addressof(obj)

(since C++11)

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*.

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

See also

copies a range of objects to an uninitialized area of memory
(function template)
copies a range of objects to an uninitialized area of memory
(algorithm function object)
copies an object to an uninitialized area of memory, defined by a range
(function template)
copies an object to an uninitialized area of memory, defined by a range
(algorithm function object)
moves a range of objects to an uninitialized area of memory
(function template)
moves a range of objects to an uninitialized area of memory
(algorithm function object)
constructs objects by default-initialization in an uninitialized area of memory, defined by a range
(function template)
constructs objects by default-initialization in an uninitialized area of memory, defined by a range
(algorithm function object)
constructs objects by value-initialization in an uninitialized area of memory, defined by a range
(function template)
constructs objects by value-initialization in an uninitialized area of memory, defined by a range
(algorithm function object)
creates an object at a given address
(function template)
creates an object at a given address
(algorithm function object)

Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.