最近,我发现实际上 perf (或 pprof)可能会在反汇编视图指令时序中显示在实际上没有花费这个时间的行附近。真正的指令,实际上花了这个时间,就在它之前。我知道一个模糊的解释,这是由于 CPU 中的指令流水线造成的。不过,我想了解以下内容:
我有以下代码:
#include <type_traits>
struct TType
{
int a = 0;
bool operator() (int&)
{
return true;
}
};
int main()
{
static_assert(std::is_same<decltype(std::declval<TType>()(std::declval<int>())), bool>::value, "wtf?");
return 0;
}
Run Code Online (Sandbox Code Playgroud)
如果我尝试用g ++ - 4.8.2编译它,那么我收到一个错误:
main.cpp:321:82: error: no match for call to ‘(JetPlane) (int)’
static_assert(std::is_same<decltype(std::declval<JetPlane>()(std::declval<int>())), bool>::value, "wtf?");
^
main.cpp:265:8: note: candidate is:
struct JetPlane
^
main.cpp:279:7: note: bool JetPlane::operator()(int&)
bool operator() (int&)
^
main.cpp:279:7: note: no known conversion for argument 1 from ‘int’ to ‘int&’
Run Code Online (Sandbox Code Playgroud)
我不明白note: no known conversion for argument 1 from …