我有以下代码:
template <typename, typename>
struct AAA{};
template<typename ...Args>
void f(AAA<Args...> *) {}
int main() {
f<int, int>(nullptr);
}
Run Code Online (Sandbox Code Playgroud)
此代码导致编译错误.使用g++ -std=c++1z
错误编译时显示如下:
prog.cc: In function 'int main()':
prog.cc:8:24: error: no matching function for call to 'f<int, int>(std::nullptr_t)'
f<int, int>(nullptr);
^
prog.cc:5:6: note: candidate: template<class ... Args> void f(AAA<Args ...>*)
void f(AAA<Args...> *) {}
^
prog.cc:5:6: note: template argument deduction/substitution failed:
prog.cc:8:24: note: mismatched types 'AAA<Args ...>*' and 'std::nullptr_t'
f<int, int>(nullptr);
Run Code Online (Sandbox Code Playgroud)
使用clang++ -std=c++1z
错误是:
prog.cc:8:5: error: no matching function for …
Run Code Online (Sandbox Code Playgroud) 从开放资源中,我可以得出结论,微代码大约可以直接由CPU执行,并负责实现指令代码。维基百科还指出,指令代码的每次执行都会经历fetch-decode-execute指令周期。但是,我找不到任何参考资料来说明在此三个阶段中如何执行微代码。所以我的问题是,微代码执行与指令周期之间的关系是什么?微码在指令执行的获取,解码和执行阶段如何工作?
同样,这个stackoverflow的答案是说,在现代的Intel CPU中,即使最简单的指令(例如DIV
和)MOV
也将在执行之前以微码进行编译,因此,如果有人真的可以用此类CPU的示例进行解释,那将是最好的。