std::experimental::is_simd, std::experimental::is_simd_mask
From cppreference.com
< cpp | experimental | simd
| ヘッダー <experimental/simd> で定義 |
||
| template< class T > struct is_simd; |
(1) | (parallelism TS v2) |
| template< class T > struct is_simd_mask; |
(2) | (parallelism TS v2) |
目次 |
[edit] テンプレートパラメータ
| T | - | チェックする型 |
[edit] ヘルパー変数テンプレート
| template< class T > constexpr bool is_simd_v = is_simd<T>::value; |
(parallelism TS v2) | |
| template< class T > constexpr bool is_simd_mask_v = is_simd_mask<T>::value; |
(parallelism TS v2) | |
std::integral_constant から継承
メンバ定数
| value [static] |
T が simd/simd_mask 型の場合 true、それ以外の場合 false(公開静的メンバ定数) |
メンバ関数
| operator bool |
オブジェクトを bool に変換し、value を返します。 (public member function) |
| operator() (C++14) |
value を返します。 (public member function) |
メンバ型
| 型 | 定義 |
value_type
|
bool |
type
|
std::integral_constant<bool, value> |
[edit] 注記
is_simd_v<T> は、T が SIMD 型として使用できるかどうかをテストするために必要ですが、十分ではありません。例えば、is_simd_v<simd<bool>> は true になりますが、bool は許可されるベクトル化可能な型に含まれていません。欠けている条件は std::is_constructible_v<T> であり、これは simd<bool> に対しては false です。
[edit] 例
このコードを実行
#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