我在两个模板的标题中收到错误。两者都有类似的声明和定义如下:
template <typename T1, typename T2> void setVideoCodecOption(T1 AVCodecContext::*option, T2 (CR2CVideoCodecSettings::*f)() const);
template <typename T1, typename T2>
void EncoderPrivate::setVideoCodecOption(T1 AVCodecContext::*option, (CR2CVideoCodecSettings::*f)() const)
{
T2 value = (m_videoSettings.*f)();
if (value != -1) {
m_videoCodecContext->*option = (m_videoSettings.*f)();
}
}
我不明白为什么我会收到这些错误。有人有想法吗?
谢谢, 熊
答案 0 :(得分:5)
您缺少第二个函数的函数参数的返回类型。
template <typename T1, typename T2>
void EncoderPrivate::setVideoCodecOption(T1 AVCodecContext::*option, (CR2CVideoCodecSettings::*f)() const)
应该是
template <typename T1, typename T2>
void EncoderPrivate::setVideoCodecOption(T1 AVCodecContext::*option, T2 (CR2CVideoCodecSettings::*f)() const)
^^^added return type