推导外部类型的模板参数

问题描述

假设我具有以下模板类:

template <typename T>
struct Hello
{
    struct Hi {};
};

我希望能够创建这样的函数

template <typename U>
void hello_hi(typename Hello<U>::Hi&)
{}

并像这样使用它:

int main()
{
    hello_hi(Hello<int>::Hi{});
}

但是C ++无法推断类型U,因为它是Hello的模板参数,不是 Hi。有什么方法可以推断出U 而没有明确设置作为hello_hi的模板参数吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)