我尝试使用默认模板参数编写此函数:
template<typename A, typename B>
void func(int i1, int i2, A a, B b = 123){
...
}
Run Code Online (Sandbox Code Playgroud)
在我看来,我可以这样称呼它:func(1, 2, 3)编译器应该从默认值推断出类型B,int但我得到了no instance of overloaded function。
在这种情况下,C++ 构造是否不正确并且编译器无法推断出类型?
c++ templates default default-arguments template-argument-deduction