다음을 고려하세요:
template<typename R>
struct call {
template<typename F, typename... Args>
explicit call(F&& f, Args&&... args);
R result;
};
template<typename R, typename F, typename... Args>
call<R>::call(F&& f, Args&&... args)
: result(std::forward<F>(f)(std::forward<Args>(args)...)) { }
클랭이 나에게 소리 친다.
utility.tpp : 40 : 1 : 오류 : 템플릿 재 선언에 템플릿 매개 변수가 너무 많습니다. template <유형 이름 R, 유형 이름 F, 유형 이름 ... Args> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ utility.hpp : 36 : 5 : 참고 : 이전 템플릿 선언은 여기에 있습니다. 템플릿 <유형 이름 R> ^ ~~~~~~~~~~~~~~~~~~~
나는 절대적으로 의아해합니다. 전혀 가능합니까?
두 개의 템플릿 이 필요합니다 . 하나는 클래스 용이고 다른 하나는 생성자 용입니다.
template <typename R> // <== for call<R>
template <typename F, typename... Args> // <== for call(F&&, Args&&...)
call<R>::call(F&& f, Args&&... args)
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다