2011-10-15 2 views
1

에이 코드를 메인에서 : 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; 
}; 
+0

C++ 11 기능 ('constexpr','decltype')을 사용했기 때문에 C++ 11을 추가했습니다. –

+0

@litb 괜찮습니다. 감사합니다. – smallB

답변

5

typename Best_Fit<Int_T>::type. 당신이 그 정의를 보여주지 않으므로, 우리는 어떤 유형인지를 알지 못합니다. 그러나 c++filt -t xlong long라고 말합니다.

typeid(...).name()은 원하는 모든 이름을 생성 할 수 있습니다. GNU libstdC++는 변환 된 타입 이름을 산출합니다.

+0

@litb 어디에서 C++ filt를 사용하는지 배울 수 있습니까? Google을 시도했지만별로 성공하지 못했습니다. – smallB

관련 문제