Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::copy_constructible

      From cppreference.com
      <cpp‎ |concepts
       
       
      Concepts library
       
      Defined in header<concepts>
      template<class T>

      concept copy_constructible=
         std::move_constructible<T>&&
         std::constructible_from<T, T&>&&std::convertible_to<T&, T>&&
         std::constructible_from<T,const T&>&&std::convertible_to<const T&, T>&&

         std::constructible_from<T,const T>&&std::convertible_to<const T, T>;
      (since C++20)

      The conceptcopy_constructible is satisfied ifT is an lvalue reference type, or if it is amove_constructible object type where an object of that type can constructed from a (possibly const) lvalue or const rvalue of that type in both direct- and copy-initialization contexts with the usual semantics (a copy is constructed with the source unchanged).

      [edit]Semantic requirements

      IfT is an object type, thencopy_constructible<T> is modeled only if given

      • v, an lvalue of type (possiblyconst)T or an rvalue of typeconst T,

      the following are true:

      • After the definitionT u= v;,u is equal tov andv is not modified;
      • T(v) is equal tov and does not modifyv.

      [edit]References

      • C++23 standard (ISO/IEC 14882:2024):
      • 18.4.14 Conceptcopy_constructible [concept.copyconstructible]
      • C++20 standard (ISO/IEC 14882:2020):
      • 18.4.14 Conceptcopy_constructible [concept.copyconstructible]

      [edit]See also

      checks if a type has a copy constructor
      (class template)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/concepts/copy_constructible&oldid=177893"

      [8]ページ先頭

      ©2009-2025 Movatter.jp