C ++ typedef typename classname :: template

I cannot make out the meaning of the following line of code:

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

This is the code for reassigning the dispenser (line 63 https://gcc.gnu.org/onlinedocs/libstdc++/libstdc++-api-4.5/a00756_source.html )

How is this different from the following?

typedef typename Allocator::rebind<Mapped>::other mapped_type_allocator;
+4
source share
2 answers
typedef typename Allocator::template rebind<Mapped>::other mapped_type_allocator;

This is a templated typedef - it sets mapped_type_allocatoras an alias for the template.


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

This is the typedef type for the type. To compile OK, Mappedyou will need to determine / know.


It is assumed that Allocator::rebind<typename X>::other(as a concept) defines a pattern, not a type.

+5
source

:

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

typename template , . , , . "" ? "typename" ?.

+2

Source: https://habr.com/ru/post/1657708/


All Articles