Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      C++ named requirements:TriviallyCopyable(since C++11)

      From cppreference.com
      <cpp‎ |named req
       
       
      C++ named requirements
       

      Note: the standard doesn't define a named requirement with this name. This is a type category defined by the core language. It is included here as a named requirement only for consistency.

      Contents

      [edit]Requirements

      The following types are collectively calledtrivially copyable types:

      [edit]Notes

      In general, for any trivially copyable typeT and an objectobj1 ofT, the underlying bytes ofobj1 can be copied into an array ofchar, orunsignedchar, orstd::byte(since C++17) or intoobj2, a distinct object ofT. Neitherobj1 norobj2 may be a potentially-overlapping subobject.

      If the underlying bytes ofobj1 are copied into such an array, and then the resulting content is copied back intoobj1,obj1 will hold its original value. If the underlying bytes ofobj1 are copied intoobj2,obj2 will holdobj1's value.

      Underlying bytes can be copied bystd::memcpy orstd::memmove, as long as no living volatile object is accessed.

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      CWG 1734C++11C++03 POD with deleted non-trivial assignment was not trivialdeleted ctors/operators allowed
      CWG 2094C++11Volatile scalar types are not trivially copyable (CWG 1746)made trivially copyable

      [edit]See also

      checks if a type is trivially copyable
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/TriviallyCopyable&oldid=177801"

      [8]ページ先頭

      ©2009-2025 Movatter.jp