Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

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

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

      Specifies that an object of the type can be copy-constructed in-place by a given allocator.

      [edit]Requirements

      Given the following types, values and expressions:

      Type Definition
      T an object type
      A an allocator type
      X a container type satisfying all following conditions:
      Value Definition
      m an lvalue of typeA
      p a pointer of typeT*
      Expression Definition
      v an expression denoting an lvalue of typeT /const T, or an rvalue of typeconst T
      exprstd::allocator_traits<A>::construct(m, p, v)

      T isCopyInsertable intoX if all following conditions are satisfied:

      • T isMoveInsertable intoX.
      • expr is well-formed.
      • Evaluatingexpr does not change the value ofv.
      • Right after the evaluation ofexpr, the value ofv is equivalent to*p.

      [edit]Notes

      IfA isstd::allocator<T>, then this will call placementnew, as by::new((void*)p) T(v)(until C++20)std::construct_at(p, v)(since C++20).

      Although it is required that customizedconstruct is used when constructing elements ofstd::basic_string until C++23, all implementations only used the default mechanism. The requirement is corrected byP1072R10 to match existing practice.

      [edit]Defect reports

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

      DRApplied toBehavior as publishedCorrect behavior
      LWG 2177C++11evalutingexpr did not have any postconditionadded
      LWG 3957C++11v could denote an rvalue of typeTexcluded
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/named_req/CopyInsertable&oldid=177548"

      [8]ページ先頭

      ©2009-2025 Movatter.jp