2
템플릿 클래스 쌍인 enable_if
구현을 이해하려고합니다. 왜 이해가 안되는데, 왜 enable_if<true, int>
이 첫 번째 것과 일치하지 않습니까? 어떻게 결정되는거야?템플릿 클래스 일치 방법
#include <iostream>
template <bool, class T = void>
struct enable_if
{
enable_if() { std::cout << "invalid type";}
};
template <class T>
struct enable_if<true, T>
{
typedef T type;
enable_if() { std::cout <<"valid type";}
};
int main(){
enable_if<0==0, int> example; // print "valid type"
return 0;
}
가장 적합하고 다른 것들. 명시 적 특수화를 선택할 수 있으면 기본 템플릿으로 기본 설정됩니다. – DeiDei
[부분 주문] (http://en.cppreference.com/w/cpp/language/partial_specialization#Partial_ordering)이라고합니다. – Praetorian