Spec-Zone.ru › C++

voidify

template< class T >
void* /*voidify*/( T& obj ) noexcept;
(constexpr since C++17)
(exposition only*)

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

construct_at
(C++20)
creates an object at a given address
(function template & algorithm function object)
ranges::construct_at
(C++20)
uninitialized_copy
copies a range of objects to an uninitialized area of memory
(function template & algorithm function object)
ranges::uninitialized_copy
(C++20)
uninitialized_copy_n
(C++11)
copies a number of objects to an uninitialized area of memory
(function template & algorithm function object)
ranges::uninitialized_copy_n
(C++20)
uninitialized_fill
copies an object to an uninitialized area of memory, defined by a range
(function template & algorithm function object)
ranges::uninitialized_fill
(C++20)
uninitialized_fill_n
copies an object to an uninitialized area of memory, defined by a start and a count
(function template & algorithm function object)
ranges::uninitialized_fill_n
(C++20)
uninitialized_move
(C++17)
moves a range of objects to an uninitialized area of memory
(function template & algorithm function object)
ranges::uninitialized_move
(C++20)
uninitialized_move_n
(C++17)
moves a number of objects to an uninitialized area of memory
(function template & algorithm function object)
ranges::uninitialized_move_n
(C++20)
uninitialized_default_construct
(C++17)
constructs objects by default-initialization in an uninitialized area of memory, defined by a range
(function template & algorithm function object)
ranges::uninitialized_default_construct
(C++20)
uninitialized_default_construct_n
(C++17)
constructs objects by default-initialization in an uninitialized area of memory, defined by a start and a count
(function template & algorithm function object)
ranges::uninitialized_default_construct_n
(C++20)
uninitialized_value_construct
(C++17)
constructs objects by value-initialization in an uninitialized area of memory, defined by a range
(function template & algorithm function object)
ranges::uninitialized_value_construct
(C++20)
uninitialized_value_construct_n
(C++17)
constructs objects by value-initialization in an uninitialized area of memory, defined by a start and a count
(function template & algorithm function object)
ranges::uninitialized_value_construct_n
(C++20)

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/cpp/memory/voidify

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API