Namespaces
Variants
Views
Actions

Difference between revisions of "cpp/concepts/copyable"

From cppreference.com
< cpp‎ | concepts
(move page (P1754R1))
 
(P2102R0)
Line 6: Line 6:
 
   std::copy_constructible<T> &&
 
   std::copy_constructible<T> &&
 
   std::movable<T> &&
 
   std::movable<T> &&
   std::assignable_from<T&, const T&>;
+
  std::assignable_from<T&, T&> &&
 +
   std::assignable_from<T&, const T&> &&
 +
  std::assignable_from<T&, const T>;
 
}}
 
}}
  
 
The concept {{tt|copyable<T>}} specifies that {{tt|T}} is an {{lconcept|movable}} object type that can also copied (that is, it supports copy construction and copy assignment).
 
The concept {{tt|copyable<T>}} specifies that {{tt|T}} is an {{lconcept|movable}} object type that can also copied (that is, it supports copy construction and copy assignment).
 
=== Notes ===
 
It is intended that {{tt|copyable<T>}} also requires {{c|std::assignable_from<T&, const T>}} (assignment from const rvalue) and {{c|std::assignable_from<T&, T&>}} (assignment from non-const lvalue) to be satisfied.
 
  
 
=== See also ===
 
=== See also ===

Revision as of 18:48, 21 June 2020

Defined in header <concepts>
template <class T>

concept copyable =
  std::copy_constructible<T> &&
  std::movable<T> &&
  std::assignable_from<T&, T&> &&
  std::assignable_from<T&, const T&> &&

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

The concept copyable<T> specifies that T is an movable object type that can also copied (that is, it supports copy construction and copy assignment).

See also

(C++20)
specifies that an object of a type can be moved and swapped
(concept) [edit]