문제

#include <list>
#include <boost/tuple/tuple.hpp>

template<class InputIterator>
void f(InputIterator it)
{
    typedef boost::tuple<typename InputIterator::value_type, int> Pair;
    std::list<Pair> paired;
    typename std::list<Pair>::const_iterator output;
    for(output=paired.begin(); output!=paired.end(); ++output)
    {
        output->get<1>();
    }
}
.

이 템플릿 함수로 라이브러리를 가져옵니다.GCC 4.1.2 ( codepad.org ) 다음 오류를보고합니다.

In function 'void f(InputIterator)':
Line 12: error: expected primary-expression before ')' token
compilation terminated due to -Wfatal-errors.
.

템플릿을 제공하는 누군가가 조언을 제공 할 수 있습니까?자신을 연구하기위한 문제 또는 핵심 문구 중 하나?이것은 나를 붙어 있습니다.

도움이 되었습니까?

해결책

get가 함수 템플리트이고 output 유형은 템플릿 매개 변수 InputIterator에 종속되므로 template 키워드를 사용해야합니다.

output->template get<1>();
.

COMEAU C ++ 템플릿 FAQ 왜 이것이 필요한 이유에 대한 좋은 설명이 있습니다..

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top