std::experimental:: is_simd, std::experimental:: is_simd_mask
|
ヘッダーで定義
<experimental/simd>
|
||
|
template
<
class
T
>
struct is_simd ; |
(1) | (parallelism TS v2) |
|
template
<
class
T
>
struct is_simd_mask ; |
(2) | (parallelism TS v2) |
目次 |
テンプレートパラメータ
| T | - | チェックする型 |
ヘルパー変数テンプレート
|
template
<
class
T
>
constexpr bool is_simd_v = is_simd < T > :: value ; |
(並列処理 TS v2) | |
|
template
<
class
T
>
constexpr bool is_simd_mask_v = is_simd_mask < T > :: value ; |
(並列処理 TS v2) | |
std:: integral_constant から継承
メンバ定数
|
value
[static]
|
true
(
T
が
simd
/
simd_mask
型の場合)、
false
(それ以外の場合)
(public static member constant) |
メンバ関数
|
operator bool
|
オブジェクトを
bool
に変換し、
value
を返す
(public member function) |
|
operator()
(C++14)
|
value
を返す
(public member function) |
メンバ型
| 型 | 定義 |
value_type
|
bool |
type
|
std:: integral_constant < bool , value > |
注記
is_simd_v
<
T
>
は、
T
がSIMD型として使用可能かどうかをテストするために必要ですが、十分条件ではありません。例えば、
is_simd_v
<
simd
<
bool
>>
は
true
ですが、
bool
は許可されたベクトル化可能な型に含まれていません。不足している条件は
std::
is_constructible_v
<
T
>
であり、これは
false
です(
simd
<
bool
>
の場合)。
例
#include <experimental/simd> #include <iostream> #include <string_view> namespace stdx = std::experimental; template<typename T> void test_simd(std::string_view type_name) { std::cout << std::boolalpha << "Type: " << type_name << '\n' << " is_simd: " << stdx::is_simd_v<T> << '\n' << " is_constructible: " << std::is_constructible_v<T> << '\n'; } template<typename T> void test_simd_mask(std::string_view type_name) { std::cout << std::boolalpha << "Type: " << type_name << '\n' << " is_simd_mask: " << stdx::is_simd_mask_v<T> << '\n' << " is_constructible: " << std::is_constructible_v<T> << "\n\n"; } int main() { test_simd<int>("int"); test_simd_mask<int>("int"); test_simd<stdx::simd<float>>("simd<float>"); test_simd_mask<stdx::simd_mask<float>>("simd_mask<float>"); test_simd<stdx::simd<bool>>("simd<bool>"); test_simd_mask<stdx::simd_mask<bool>>("simd_mask<bool>"); }
出力:
Type: int is_simd: false is_constructible: true Type: int is_simd_mask: false is_constructible: true Type: simd<float> is_simd: true is_constructible: true Type: simd_mask<float> is_simd_mask: true is_constructible: true Type: simd<bool> is_simd: true is_constructible: false Type: simd_mask<bool> is_simd_mask: true is_constructible: false