提问人:Fareanor 提问时间:10/10/2023 更新时间:10/10/2023 访问量:92
需要模板说明符在概念上将类型视为依赖模板名称 requires 子句
Need of template specifier to treat a type as a dependent template name in concept requires clause
问:
免責聲明:这个问题纯粹是出于好奇,我不打算使用这样的结构(我什至想不出这样一个概念的相关用例)。
如果我们考虑以下概念(以表示具有定义的内部模板类型的约束):
template <typename T, typename U>
concept has_template_type = requires(T)
{
typename T::template type<U>;
};
我注意到,如果我删除子句中的说明符(即如果我改写),g++ 仍然接受这个概念,而 clang++ 拒绝它,并附上以下内容:template
requires
typename T::type<U>;
<source>:4:18: error: use 'template' keyword to treat 'type' as a dependent template name 4 | typename T::type<U>; | ^ | template 1 error generated.
GCC 是否正确/允许隐式推断出这是一个依赖模板名称?type
虽然我怀疑 Clang 是对的,但我想得到确认并知道为什么。
答: 暂无答案
评论
typename
template
typename
typename
typename
typename