名稱空間
變體
操作

std::move_constructible

來自 cppreference.com
定義於標頭檔案 <concepts>
template< class T >
concept move_constructible = std::constructible_from<T, T> && std::convertible_to<T, T>;
(C++20 起)

概念 move_constructible 被滿足,如果 T 是引用型別,或者它是物件型別,並且該型別的物件可以在直接初始化和複製初始化上下文中從該型別的右值構造,並具有通常的語義。

[編輯] 語義要求

如果 T 是物件型別,則 move_constructible<T> 僅在給定以下條件時才成立:

  • rv,一個型別為 T 的右值,以及
  • u2,一個型別為 T 且等於 rv 的不同物件,

以下條件為真

  • 在定義 T u = rv; 之後,u 等於 u2
  • T(rv) 等於 u2;並且
  • 如果 T 不是 const 限定的,則 rv 的結果狀態(在上述任何一個要點中的定義/表示式求值之後)是有效的但未指定;否則,它保持不變。

[編輯] 參考資料

  • C++23 標準 (ISO/IEC 14882:2024)
  • 18.4.13 概念 move_constructible [concept.moveconstructible]
  • C++20 標準 (ISO/IEC 14882:2020)
  • 18.4.13 概念 move_constructible [concept.moveconstructible]

[編輯] 參閱

檢查型別是否可以從右值引用構造
(類模板) [編輯]