为什么 C++ 标准不允许函数模板部分特化? [英] Why does the C++ standard not allow function template partial specialization?

查看:38
本文介绍了为什么 C++ 标准不允许函数模板部分特化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我读到一些编译器可能会写的令人困惑的内容

I read something that it might be confusing for the compiler to write

template <class T>
void calculator<std::complex<T>>::myMin();

但也许只是给它一个提示?明确说明它是部分专业化.

but maybe just give it a hint like so? To make it clear that it is a partial specialization.

template < , class T>
void calculator<std::complex<T>>::myMin();

推荐答案

来自 http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#229 由@danh 在上述评论中链接:

From http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#229 linked by @danh in the comments above:

10/00 会议记录:

函数模板的部分特化思想的一个主要问题是函数模板可以被重载,这与类模板不同.简单地命名特化中的函数模板,就像在类特化中所做的那样,不足以识别被特化的模板.

A major concern over the idea of partial specialization of function templates is that function templates can be overloaded, unlike class templates. Simply naming the function template in the specialization, as is done for class specialization, is not adequate to identify the template being specialized.

这篇关于为什么 C++ 标准不允许函数模板部分特化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆