에이 코드를 메인에서 : GCC 4.6.1로 codeblocks 컴파일 동안유형 이름은 이상한 결과를 제공 - codeblocks
Int<> a;
cout << typeid(Int<>::range_type).name();
출력을 'x'를 제공합니다. 그 이유가 뭐야? 당신이 Signed_Type
을 얻을 것입니다 수행 인스턴스에서
template<class Int_T>
struct Best_Fit
{//evaluate it lazily ;)
typedef typename if_<std::is_signed<Int_T>::value,Signed_Type,Unsigned_Type>::type type;
};
template<class Int_T = int, typename Best_Fit<Int_T>::type Min_Range = std::numeric_limits<Int_T>::min(), typename Best_Fit<Int_T>::type Max_Range = std::numeric_limits<Int_T>::max()>
class Int {
public:
typedef decltype(Min_Range) range_type;
};
C++ 11 기능 ('constexpr','decltype')을 사용했기 때문에 C++ 11을 추가했습니다. –
@litb 괜찮습니다. 감사합니다. – smallB