【发布时间】:2018-01-28 10:43:05
【问题描述】:
this question 的跟进。假设占位符可用于推断构成非类型模板参数的函数指针的结果类型。 c++17 是否允许在传递给模板函数名称时执行重载解析 - 在不知道结果类型的情况下,执行隐式转换需要这样做吗?
template <auto(*)(int)>
struct Foo { };
int bar(int);
float bar(float);
int main() {
static_cast<void>(Foo<bar>{});
}
【问题讨论】:
-
@Rakete1111 不错!!我认为它涵盖了这个问题,谢谢!
-
@Rakete1111 我认为子弹在 c++14 中已经存在... :o 当时这个子弹的用途是什么?
-
跟现在的用法一样。除非你从重载集中选择一个特定的函数,你自己为模板参数指定返回类型。
标签: c++ templates language-lawyer c++17