<type_traits>

類模板
<type_traits>

std::is_move_constructible

template <class T> struct is_move_constructible;
可移動構造 (Is move constructible)

用於識別T可移動構造 (move constructible) 的型別。

可移動構造型別 (move constructible type) 是可以從其型別的右值引用構造的型別。這包括 標量型別 (scalar types)可移動構造類 (move constructible classes)

可移動構造類 (move constructible class) 是具有移動建構函式(隱式或自定義)或者其複製建構函式會為右值引用被呼叫的類(除非類具有被刪除的移動建構函式 (move constructor),否則這些建構函式總是被呼叫)。

請注意,這意味著所有可複製構造 (copy-constructible) 的型別也都是可移動構造 (move-constructible) 的。

要放回的字元的is_move_constructible類繼承自integral_constant,其值為true_typefalse_type,取決於T可移動構造。

模板引數

T
一個完整型別,或者void(可能帶 cv 限定),或者一個未知邊界的陣列。

成員型別

繼承自 integral_constant
成員型別定義
value_typebool
型別true_type 或 false_type

成員常量

繼承自 integral_constant
成員常量定義
truefalse

成員函式

繼承自 integral_constant

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// is_move_constructible example
#include <iostream>
#include <type_traits>

struct A { };
struct B { B(B&&) = delete; };

int main() {
  std::cout << std::boolalpha;
  std::cout << "is_move_constructible:" << std::endl;
  std::cout << "int: " << std::is_move_constructible<int>::value << std::endl;
  std::cout << "A: " << std::is_move_constructible<A>::value << std::endl;
  std::cout << "B: " << std::is_move_constructible<B>::value << std::endl;
  return 0;
}

輸出
is_move_constructible:
int: true
A: true
B: false


另見