Namespaces
Variants

std::experimental:: is_simd, std::experimental:: is_simd_mask

From cppreference.net
헤더 파일에 정의됨 <experimental/simd>
template < class T >
struct is_simd ;
(1) (parallelism TS v2)
template < class T >
struct is_simd_mask ;
(2) (parallelism TS v2)
1) 만약 T simd 클래스 템플릿의 특수화(specialization)인 경우, 멤버 상수 value true 로 제공합니다. 다른 모든 타입에 대해서는 value false 입니다.
2) 만약 T simd_mask 클래스 템플릿의 특수화(specialization)라면, 멤버 상수 value true 와 같음을 제공합니다. 다른 모든 타입에 대해서는 value false 입니다.

목차

템플릿 매개변수

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