Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      voidify

      From cppreference.com
      <cpp‎ |memory
       
       
      Memory management library
      voidify
      (exposition only*)
      Allocators
      Uninitialized memory algorithms
      Constrained uninitialized memory algorithms
      Memory resources
      Uninitialized storage(until C++20)
      (until C++20*)
      (until C++20*)
      Garbage collector support(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)(until C++23)
       
      template<class T>
      void* voidify( T& obj)noexcept;
      (exposition only*)
      (constexpr since C++17)

      Returns the address ofobj (implicitly converted tovoid*).

      Contents

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

      [edit]Defect reports

      The following behavior-changing defect reports were applied retroactively to previously published C++ standards.

      DRApplied toBehavior as publishedCorrect behavior
      LWG 3870C++98the explicit casts broke const-correctnessremoved these casts

      [edit]See also

      copies a range of objects to an uninitialized area of memory
      (function template)[edit]
      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]
      copies an object to an uninitialized area of memory, defined by a range
      (algorithm function object)[edit]
      moves a range of objects to an uninitialized area of memory
      (function template)[edit]
      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]
      creates an object at a given address
      (function template)[edit]
      creates an object at a given address
      (algorithm function object)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/memory/voidify&oldid=179579"

      [8]ページ先頭

      ©2009-2025 Movatter.jp