Namespaces
Variants

voidify

From cppreference.com
 
 
Algorithm library
Constrained algorithms and algorithms on ranges (C++20)
Constrained algorithms, e.g. ranges::copy, ranges::sort, ...
Non-modifying sequence operations    
Batch operations
(C++17)
Search operations
Modifying sequence operations
Copy operations
(C++11)
(C++11)
Swap operations
Transformation operations
Generation operations
Removing operations
Order-changing operations
(until C++17)(C++11)
(C++20)(C++20)
Sampling operations
(C++17)

Sorting and related operations
Partitioning operations
(C++11)    

Sorting operations
Binary search operations
(on partitioned ranges)
Set operations (on sorted ranges)
Merge operations (on sorted ranges)
Heap operations
Minimum/maximum operations
(C++11)
(C++17)
Lexicographical comparison operations
Permutation operations


 
 
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 template is introduced by P0896R4. It is used to describe the effects of specialized <memory> algorithms. 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

creates an object at a given address
(function template & algorithm function object)[edit]
copies a range of objects to an uninitialized area of memory
(function template & algorithm function object)[edit]
copies a number of objects to an uninitialized area of memory
(function template & algorithm function object)[edit]
copies an object to an uninitialized area of memory, defined by a range
(function template & algorithm function object)[edit]
copies an object to an uninitialized area of memory, defined by a start and a count
(function template & algorithm function object)[edit]
moves a range of objects to an uninitialized area of memory
(function template & algorithm function object)[edit]
moves a number of objects to an uninitialized area of memory
(function template & algorithm function object)[edit]
constructs objects by default-initialization in an uninitialized area of memory, defined by a range
(function template & algorithm function object)[edit]
constructs objects by default-initialization in an uninitialized area of memory, defined by a start and a count
(function template & algorithm function object)[edit]
constructs objects by value-initialization in an uninitialized area of memory, defined by a range
(function template & algorithm function object)[edit]
constructs objects by value-initialization in an uninitialized area of memory, defined by a start and a count
(function template & algorithm function object)[edit]