<type_traits>

類模板
<type_traits>

std::is_trivially_move_constructible

template <class T> struct is_trivially_move_constructible;
是否可平凡移動構造

用於識別T是否是 *可平凡移動構造* 型別的特性類。

一個*可平凡移動構造型別*是透過右值引用可以平凡構造的型別。這包括*標量型別*、*可平凡移動構造類*及其陣列。

一個*可平凡移動構造類*是一個類(使用, struct聯合體定義)
  • 使用隱式定義的移動建構函式。
  • 沒有虛成員。
  • 其基類和非靜態資料成員(如果有)本身也是*可平凡移動構造型別*。

要放回的字元的is_trivially_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
16
17
// is_trivially_move_constructible example
#include <iostream>
#include <type_traits>

struct A { };
struct B { B(B&&){} };
struct C { virtual void fn() {} };

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

輸出
is_trivially_move_constructible:
int: true
A: true
B: false
C: false


另見