我有一个问题,我正在尝试将类模板的朋友函数填充到boost :: function中:
#include
template
struct Vec{
friend
double dot(Vec, Vec){}
};
template class Vec<2>; //Force multiple instantiations
template class Vec<3>;
int main()
{
boost::function, Vec<2>)> func = dot;
double (*func1)(Vec<2>, Vec<2>) = dot;
}
main中的两行都不会编译.对于第一个,GCC抱怨:
error: conversion from '' to non-scalar type 'boost::function, Vec<2>)>' requested
第二行的错误似乎让我更加困惑:
error: no matches converting function 'dot' to type 'double (*)(struct Vec<2>, struct Vec<2>)'
testtmpl.C:6:15: error: candidates are: double dot(Vec<2>, Vec<2>)
testtmpl.C:6:15: error: double dot(Vec<3>, Vec<3>)
我有点受阻,因为我不明白为什么双点(Vec< 2>,Vec< 2>)不匹配.
关于这里发生了什么的任何想法?