C++ typedef typename classname::template

编程入门 行业动态 更新时间:2024-10-10 19:24:25
本文介绍了C++ typedef typename classname::template的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我无法解析以下代码行的含义:

I am not able to parse the meaning of the following line of code:

typedef typename Allocator::template rebind<Mapped>::other mapped_type_allocator;

这是分配器重新绑定的代码(第 63 行https://gcc.gnu/onlinedocs/libstdc++/libstdc++-api-4.5/a00756_source.html)

This is the code for allocator rebinding (line 63 of https://gcc.gnu/onlinedocs/libstdc++/libstdc++-api-4.5/a00756_source.html)

这与以下有何不同?

typedef typename Allocator::rebind<Mapped>::other mapped_type_allocator;

推荐答案

typedef typename Allocator::template rebind<Mapped>::other mapped_type_allocator;

这是一个 模板化的 typedef - 它建立了 mapped_type_allocator 作为一个别名模板.

This is a templated typedef - it establishes mapped_type_allocator as an alias for a template.

typedef typename Allocator::rebind<Mapped>::other mapped_type_allocator;

这是一个类型的 typedef.要编译 OK,Mapped 需要定义/已知.

This is a typedef for a type. To compile OK, the Mapped would need to be defined/known.

Allocator::rebind::other(作为一个概念)应该定义一个模板,而不是一个类型.

The Allocator::rebind<typename X>::other (as a concept) is expected to define a template, not a type.

这篇关于C++ typedef typename classname::template的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 06:13:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405420.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:typename   typedef   template   classname

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!