2017-04-02 2 views
0

코드를 SIMD화할 때마다 각 유형 케이스를 처리하기 위해 템플릿 전문화를 사용하기로 결정했지만 잘못된 것으로 보입니다. (: 구문 오류 : "< 끝 구문 분석>"C2059) 다음 : 전체 템플릿 전문화 오류

template<typename T> struct __declspec(align(16)) TVec2 
{ 
}; 

template<> __declspec(align(16)) struct TVec2<s64> 
{ 
    union 
    { 
     struct 
     { 
      s64 x, y; 
     }; 
     struct 
     { 
      __m128i v; 
     }; 
    }; 
    TVec2() 
    { 
     v = _mm_setzero_si128(); 
    } 
    TVec2(s64 scalar) 
    { 
     v = _mm_set_epi64x(scalar, scalar); 
    } 
    TVec2(s64 x, s64 y) 
    { 
     v = _mm_set_epi64x(x, y); 
    } 
    template<typename U> operator TVec2<U>() const 
    { 
     return TVec2<U>(static_cast<U>(x), static_cast<U>(y)); 
    } 
    s64& operator[](word index) 
    { 
     return v.m128i_i64[index]; 
    } 
    const s64& operator[](word index) const 
    { 
     return v.m128i_i64[index]; 
    } 
}; 
// There are other specializations but they produce the same errors 

내가 비주얼 스튜디오 (2015) 내가 할 (unrecognizeable 템플릿 선언/정의 C2988)에 컴파일

. 전문화를위한 문서를 올바르게 따라 갔는지 확신하지만 오류가 발생하기 쉽습니다.

답변

1

구조 키워드 앞에 __declspec이 작성되어 템플릿이 제대로 인식되지 않아서 문제가 발생한 것 같습니다. alignas specifier을 사용하고 이름없는 구조체/노동 조합을 제거 것도 좋은 생각 일 수있다

template<> struct __declspec(align(16)) TVec2<s64> 

로 변경하십시오.

+0

와우, 그게 간단한 문제였습니다. 발견해 주셔서 감사합니다. – Jarann