此例子来源于《C++Templates The Complete Guide》,
使用了两种编译器(gcc 3.4.4, Dev-C++ 4.9.9.2),都出现如下错误:
C++ Templates中的functor源代码。编译其中的一个cpp文件(compose6.cpp)即可。
下载地址:
http://www.josuttis.com/tmplbook/examples.zip
编译错误:
dell@dell-PC /cygdrive/g/cyghome/src/cpptemplates/functors $ make g++.exe compose6.cpp -o test.exe
In file included from forwardparam.hpp:15,
from functionptr.hpp:11,
from funcptr.hpp:11,
from compose6.cpp:12:
typet.hpp:73: error: expected primary-expression before '>' token
typet.hpp: In instantiation of `IsFunctionT<double>':
typet.hpp:105: instantiated from `CompoundT<double>'
typet.hpp:290: instantiated from `TypeT<double>'
forwardparam.hpp:29: instantiated from `ForwardParamT<double>'
functionptr.hpp:39: instantiated from `FunctionPtr<double, double, double, voi
d>'
compose6.cpp:29: instantiated from here
typet.hpp:73: error: enumerator value for `Yes' not integer constant
make: *** [test.exe] Error 1
解决方法:去掉IsFunctionT<T>::