问题描述
限时送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
(作为一个概念)应该定义一个模板,而不是一个类型.
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:关键词]
发布评论