关于模板替换示例的混淆

use*_*849 1 c++ variadic-functions sfinae c++11

我对"The C++ programming language 4th,28.4.4"中的代码感到困惑

template<typename T>
struct get_f_result {
private:
    template<typename X>
    static auto check(X const& x) ?> decltype(f(x)); // can call f(x)
    static substitution_failure check(...); // cannot call f(x)
public:
    using type = decltype(check(std::declval<T>()));
};
Run Code Online (Sandbox Code Playgroud)

我特别困惑的部分是这一行:

static substitution_failure check(...); // cannot call f(x)
Run Code Online (Sandbox Code Playgroud)

但我记得...不能接受非豆荚类型?那怎么可能呢?

Mik*_*our 5

...可以采取任何类型; 可能不支持传递非POD类型,但在语法上有效.

在这种情况下,不评估函数调用(因为它仅在未评估的上下文中用作操作数decltype),因此没有未定义的行为,只是编译时尝试将函数调用与适当的重载匹配.