2013-06-12 2 views
0

내에서 허용된다오류 (A disambiguator 등) '템플릿'에만 나는 다음과 같은 정의가 템플릿

typedef boost::multi_index_container< 
    ModelPtr, 
    boost::multi_index::indexed_by< 
    boost::multi_index::sequenced<boost::multi_index::tag<byInsertOrder> >, // to keep order of inserting 
    boost::multi_index::ordered_non_unique< boost::multi_index::tag<byPriority>, 
              boost::multi_index::const_mem_fun<IModel, 
              unsigned int, 
              &IModel::getPriority>, 
              std::greater< unsigned int> // from the highest priority to the lowest 
              > 
    > 
    > ModelContainer; 

typedef ModelContainer::template index<AOActivationList::byInsertOrder>::type ModelByInsertOrderType; (*) 

문제는 내가 GCC 4.5.3로 컴파일 할 때 나는 다음과 같은 오류를 얻을 수 있습니다 : 오류 : 템플릿 내 '템플릿'(제외 어)은 템플릿 내에서만 허용됩니다. (*)이 표시된 행. Visual Studio 2008에서는 컴파일됩니다.

그 이유는 무엇입니까? 그것을 고치는 방법? 이 라인에

답변

2

: ModelContainer는 현재 범위에서 비 고정 template 매개 변수에 의존하는 유형 인 경우에만 유효한 경우입니다 ModelContainer::template ...를 사용하여 당신이하는 template 내에하지 않는

typedef ModelContainer::template index<AOActivationList::byInsertOrder>::type ModelByInsertOrderType 

는 단어 template를 제거합니다.

컴파일러가 해당 라인에서 ModelContainer의 전체 유형을 알아낼 수있는 경우 template을 사용할 수 없습니다. 확실하지 않은 경우 template을 사용해야합니다.

주어진 스튜디오 코드를 컴파일하거나 컴파일하지 않기로 결정한 Visual Studio의 결정은 코드가 모든 표준에 따라 C++ 코드로 유효하다는 증거는 거의 없습니다.

관련 문제