模板名称< TT>是否为推论的上下文? [英] Is template-name<TT> a deduced context?

查看:76
本文介绍了模板名称< TT>是否为推论的上下文?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[temp.deduct.type]第8段列表所有推论的上下文,但似乎不包括 template-name <TT>,其中 template-name 是指类模板,而TT是指模板模板参数.这是推论的上下文吗?

[temp.deduct.type] paragraph 8 lists all deduced contexts, but it seems not to include template-name<TT> where template-name refers to a class template and TT refers to a template template argument. Is this a deduced context?

如果是,为什么?

如果没有,请考虑以下代码:

If not, consider the following code:

template<template<typename> class U, template<typename> class V>
struct foo {};

template<template<typename> class U>
struct foo<U, U> {}; 

int main() {}

此代码在Clang 7.0.0下编译

This code compiles under Clang 7.0.0 and GCC 8.0.1, which means the compilers consider the partial specialization is more specialized than the primary template, which means U and V in the primary template are successfully deduced against foo<U, U>. Is this a compiler bug?

推荐答案

本段充满了问题,包括您指出的问题. 核心问题2328 有一个不错的列表:

This paragraph is full of problems, including the one you pointed out. Core issue 2328 has a nice list:

17.9.2.5 [temp.deduct.type]第8段的显示方式 导致规范不明确,不必要冗长,并且 不完整.具体问题包括:

The presentation style of 17.9.2.5 [temp.deduct.type] paragraph 8 results in a specification that is unclear, needlessly verbose, and incomplete. Specific problems include:

  • PA具有一组格式中的一个是什么意思?他们俩都必须有该表格吗? (这不会发生;通常, 仅P包含模板参数)

  • What does it mean for P and A to have one of a set of forms? Do they both have to have that form? (That doesn't happen; typically, only P contains template parameters)

在介绍性句子中,不是TTTi应该是模板参数而不是模板参数的名称吗?

In the introductory sentence, aren't T, TT, and i supposed to be the names of template parameters rather than template arguments?

T[i]中,似乎可以推断出i,但不能推断出T(T只能以T[integer-constant]的形式推导)

In T[i], it appears we can deduce i, but not T (T can only be deduced in the form T[integer-constant])

integer-constant 应该是什么?

What is an integer-constant supposed to be?

什么是 cv-list ?

为什么不能从T推论出const T? (很明显,只有两种类型或两种类型都没有 cv-list 时,您才能推断出 cv-list 是.)

Why can we not deduce const T from T? (Apparently you only get to deduce if both or neither type have a cv-list, whatever a cv-list is.)

我们具有极大的冗余性,例如,没有办法说在T (T::*)(T)中,您可以推断出任何这些T,而且还可以 如果某些职位没有T".因此,我们有七个(!)表单 该构造的所有情况下,除了所有情况下, 三个位置包含T.

We have extreme redundancy because, for instance, there is no way to say "in T (T::*)(T), you can deduce any of those Ts, and it's OK if some of the positions don't have a T". So we have seven (!) forms of that construct, for all cases except the one where none of the three positions contain a T.

对于成员函数的指针,我们有特殊情况规则,即使它们不是特殊情况,也应包含在规则中 指向成员的指针和函数规则.

We have special case rules for pointers to member functions, even though they're not a special case and should be covered by the rule for pointers to members and the rule for functions.

我们不允许从模板模板参数推导出模板模板参数的值-有一个TT<T>形式,一个TT<i> 表格,template-name<T>表格和 template-name<i>形式,但没有TT<TT>形式 也不是template-name<TT>表单.

We do not allow deducing a template template parameter's value from a template template argument — there is a TT<T> form, a TT<i> form, a template-name<T> form, and a template-name<i> form, but no TT<TT> form nor template-name<TT> form.

至少自从问题提交以来,看来编辑器设法摆脱了 cv-list .现在只是 cv . ( cv-list 有点荒谬,因为[语法]说 -list 后缀是逗号分隔的列表...)

It looks like the editor managed to get rid of cv-list, at least, since the issue was filed. It's now just cv. (cv-list is kind of hilariously wrong, because [syntax] says that the -list suffix is for comma-separated lists...)

这篇关于模板名称&lt; TT&gt;是否为推论的上下文?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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