visual-studio - 使用本机事件的 C++ 内部编译器错误
问题描述
__event T e(args);
在第 9 行,VS 在“e”下给了我绿色的波浪线,并带有警告:“e”的函数定义未找到。
在编译/构建时,它会抛出编译器中发生的 C1001 内部错误(再次是第 9 行)。
我尝试重命名变量,尝试删除模板并仅使用普通类型,尝试将其公开。
如果有人可以提供帮助,将不胜感激,谢谢。(整个代码可能不是必需的,只是为了说明我要做什么)
#include <cstdarg>
#include <functional>
#include <iostream>
template <typename T, typename ... args>
[event_source(native)]
class Action {
private:
__event T e(args);
public:
~Action() {
__unhook(this);
};
void operator +=(std::function<T(args...)> f) {
__hook(e, this, &f);
}
void operator -=(std::function<T(args...)> f) {
__unhook(e, this, &f);
}
void operator()(args...) {
__raise e(args);
}
};
void print(const char* s) {
std::cout << s << std::endl;
}
int main() {
Action<void, const char*> printAction;
printAction += print;
printAction("Print a string.");
printAction -= print;
}
解决方案
推荐阅读
- layout - 全屏设计
- java - 如何在 Java 8 中的 java.util.Date 中获取特定时间
- ruby-on-rails - Rspec stub_const 竞争条件
- gtk - GTK:单击鼠标时如何确定 ctl/alt 键状态?
- javascript - 如何在多选引导下拉 jquery 中选择 2 个下拉列表的基础上添加/删除列表中的元素?
- java - Eclipse 无法运行带有模块警告的 java 项目
- typescript - 如何使用联系人数据返回客户数据,如果客户没有联系人,则返回客户数据
- oauth-2.0 - 如何创建一个 FusionAuth 应用程序,其中包含许多具有范围的 oauth 客户端
- laravel - 如何使用 VueJS (+ Laravel) 自动显示模态
- opengl - GLSL 片段着色器中的 2D 颜色网格