| Technical Specification | ||||
| Filesystem library(filesystem TS) | ||||
| Library fundamentals(library fundamentals TS) | ||||
| Library fundamentals 2(library fundamentals TS v2) | ||||
| Library fundamentals 3(library fundamentals TS v3) | ||||
| Extensions for parallelism(parallelism TS) | ||||
| Extensions for parallelism 2(parallelism TS v2) | ||||
| Extensions for concurrency(concurrency TS) | ||||
| Extensions for concurrency 2(concurrency TS v2) | ||||
| Concepts(concepts TS) | ||||
| Ranges(ranges TS) | ||||
| Reflection(reflection TS) | ||||
| Mathematical special functions(special functions TR) | ||||
| Experimental Non-TS | ||||
| Pattern Matching | ||||
| Linear Algebra | ||||
| std::execution | ||||
| Contracts | ||||
| 2D Graphics |
| Parallel exceptions | ||||
| Additional execution policies | ||||
| Algorithms | ||||
| Task blocks | ||||
| Data-parallel vectors | ||||
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) |
T is a specialization of thesimd class template, provides the member constantvalue equaltrue. For any other type,value isfalse.T is a specialization of thesimd_mask class template, provides the member constantvalue equaltrue. For any other type,value isfalse.Contents |
| T | - | a type to check |
template<class T> constexprbool is_simd_v= is_simd<T>::value; | (parallelism TS v2) | |
template<class T> constexprbool is_simd_mask_v= is_simd_mask<T>::value; | (parallelism TS v2) | |
value [static] | true ifT is asimd/simd_mask type,false otherwise(public static member constant) |
operator bool | converts the object tobool, returnsvalue (public member function) |
operator() (C++14) | returnsvalue (public member function) |
| Type | Definition |
value_type | bool |
type | std::integral_constant<bool, value> |
is_simd_v<T> is necessary but not sufficient for testing whetherT can be used as a SIMD type. For example,is_simd_v<simd<bool>> istrue, even thoughbool is not included in the permissible vectorizable types. The missing condition isstd::is_constructible_v<T>, which isfalse forsimd<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>");}
Output:
Type: int is_simd: false is_constructible: trueType: int is_simd_mask: false is_constructible: true Type: simd<float> is_simd: true is_constructible: trueType: simd_mask<float> is_simd_mask: true is_constructible: true Type: simd<bool> is_simd: true is_constructible: falseType: simd_mask<bool> is_simd_mask: true is_constructible: false