매개 변수 T_rhs
모두 기본 유형이 아니므로 내 코드는 프리미티브 유형을 반환하는 cast_to_primitive()
함수를 구현하는 클래스를 나타내도록 설계되었습니다. 이 첫 번째 경우에는 T_res
유형이 decltype(std::declval<T_rhs>().cast_to_primitive())
유형의 요소로 decltype(std::declval<T_lhs>().cast_to_primitive())
유형의 요소로 나눈 유형을 갖기를 원합니다. T_lhs
또는 T_rhs
하나는 원시 타입 (또는 둘 다) 상기 제 2에서는 유형 정의는, 내가 <code>A</code>의 템플릿 매개 변수 <code>T_lhs</code> 및 <code>T_rhs</code>에 따라 유형 <code>T_res</code>을 정의 할 템플릿 클래스 <code>A</code> 감안할 때
T_rhs
의 요소에 의해 입력
T_lhs
의 엘리먼트를 분할함으로써 얻어지는 형태를 가질
T_res
원한다. 예를 들어,
T_lhs
이 기본 유형 인 경우 내 코드는
T_rhs
이
T_lhs
유형의 요소에 내재적으로 형변환 될 수 있도록 설계되었습니다.
T_rhs
이 프리미티브 인 경우에도 마찬가지입니다.
불행히도 위의 코드는 컴파일되지 않습니다. 오류 :
error: template non-type parameter has a different type 'std::enable_if_t<(lhs_is_fundamental || rhs_is_fundamental)> *' (aka 'typename enable_if<(lhs_is_fundamental || rhs_is_fundamental), void>::type *') in template redeclaration
std::enable_if_t<(lhs_is_fundamental || rhs_is_fundamental)>* = nullptr >
^
note: previous non-type template parameter with type 'std::enable_if_t<(!lhs_is_fundamental && !rhs_is_fundamental)> *' (aka 'typename enable_if<(!lhs_is_fundamental && !rhs_is_fundamental), void>::type *') is here
std::enable_if_t<(!lhs_is_fundamental && !rhs_is_fundamental)>* = nullptr >
^
문제를 해결하는 데 도움을 줄 수있는 사람이 있습니까? std::conditional
인스턴스화 한 후
' std :: conditional_t <..>'도움이 될 수 있습니다. – Jarod42
A 클래스의 목적이 무엇인지 알면 도움이됩니다. – Rerito