std::experimental::is_simd, std::experimental::is_simd_mask - cppreference.com (original) (raw)

Defined in header <experimental/simd>
template< class T > struct is_simd; (1) (parallelism TS v2)
template< class T > struct is_simd_mask; (2) (parallelism TS v2)
  1. If T is a specialization of the simd class template, provides the member constant value equal true. For any other type, value is false.

  2. If T is a specialization of the simd_mask class template, provides the member constant value equal true. For any other type, value is false.

Contents

[edit] Template parameters

[edit] Helper variable template

| 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) |

Inherited from std::integral_constant

Member constants

| | true if T is a simd/simd_mask type, false otherwise (public static member constant) | | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

Member functions

| | converts the object to bool, returns value (public member function) | | ---------------------------------------------------------------------- | | | returns value (public member function) |

Member types

[edit] Notes

is_simd_v<T> is necessary but not sufficient for testing whether T can be used as a SIMD type. For example, is_simd_v<simd<bool>> is true, even though bool is not included in the permissible vectorizable types. The missing condition is std::is_constructible_v<T>, which is false for simd<bool>.

[edit] Example

#include <experimental/simd> #include #include   namespace stdx = std::experimental;   template void test_simd(std::string_view type_name) { std::cout << std::boolalpha << "Type: " << type_name << '\n' << " is_simd: " << stdx::is_simd_v << '\n' << " is_constructible: " << std::is_constructible_v << '\n'; }   template 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 << '\n' << " is_constructible: " << std::is_constructible_v << "\n\n"; }   int main() { test_simd("int"); test_simd_mask("int");   test_simd<stdx::simd>("simd"); test_simd_mask<stdx::simd_mask>("simd_mask");   test_simd<stdx::simd>("simd"); test_simd_mask<stdx::simd_mask>("simd_mask"); }

Output:

Type: int is_simd: false is_constructible: true Type: int is_simd_mask: false is_constructible: true   Type: simd is_simd: true is_constructible: true Type: simd_mask is_simd_mask: true is_constructible: true   Type: simd is_simd: true is_constructible: false Type: simd_mask is_simd_mask: true is_constructible: false