以下代码在升级到vs19之前运行良好:
template <typename... Args> constexpr Function Callback(std::function<void(Args...)> const f) {
return [=]() {
GlobalVar=sum((std::is_base_of<BaseC,std::remove_pointer<std::remove_reference<Args>::type>::type>::value)...);
f((static_cast<Args>(GetVar))...); };
};}
该代码适用于带有函数参数的模板函数,该函数返回一个lambda以使用GetVar的值执行参数(这是具有重载运算符的类实例),但是只是在将全局变量设置为函数将获得一个基类BaseC或它的指针或引用。
现在抛出这些错误:
Error C2275 'std::remove_reference<int>::type': illegal use of this type as an expression
Error C2275 'std::remove_pointer<_Ty>::type': illegal use of this type as an expression
Error C2275 'std::remove_reference<char *>::type': illegal use of this type as an expression
Error C2955 'std::remove_pointer': use of class template requires template argument list
Error C2955 'std::is_base_of': use of class template requires template argument list
Error C2923 'std::remove_pointer': 'std::remove_reference<int>::type' is not a valid template type argument for parameter '_Ty'
Error C2923 'std::is_base_of': 'std::remove_pointer<_Ty>::type' is not a valid template type argument for parameter '_Derived'