2017-03-03 1 views
3

내가어떻게 예를</p> <pre><code>struct Option_1 { template<class T> using Vector = std::vector<T>; }; </code></pre> <p>를 들어

typename Option_1::Vector<int> v; 

을 할 수있는 클래스의 템플릿의 유형 별칭을 정의하지만은 포함하지 않는

Vector<Option_1, int> v; 

또는 Similars 참조를 다음과 선호 단어 "typename". 별칭을 정의합니다.

template<class Option, class T> using Vector= typename Option::Vector<T>; 

하지만 인식 할 수없는 템플릿 선언/정의에서는 실패했습니다. 그것을 고치는 방법? 당신은 종속 템플릿 이름 Option::Vector의 키워드 template를 사용해야합니다

+0

참조 : * 어디에 왜 내가 "템플릿"과 "유형 이름"키워드를 넣어해야합니까 ?] (http://stackoverflow.com/questions/610245/where-and-why-do-i-have-to-put-the-template-and-typename-keywords) *. – Pixelchemist

답변

1

, 즉

template<class Option, class T> using Vector = typename Option::template Vector<T>; 
//                ~~~~~~~~ 

LIVE