This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Introduce gdb::byte_vector, add allocator that default-initializes
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Pedro Alves <palves at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Fri, 23 Jun 2017 11:52:01 +0100
- Subject: Re: [PATCH] Introduce gdb::byte_vector, add allocator that default-initializes
- Authentication-results: sourceware.org; auth=none
- References: <1497287225-16542-1-git-send-email-palves@redhat.com>
Pedro Alves <palves@redhat.com> writes:
Hi Pedro,
I happen to read this code when I am writing a stack allocator,
> + /* Override rebind. */
> + template<typename U>
> + struct rebind
> + {
> + /* A couple helpers just to make it a bit more readable. */
> + typedef std::allocator_traits<A> traits_;
> + typedef typename traits_::template rebind_alloc<U> alloc_;
> +
> + /* This is what we're after. */
> + typedef default_init_allocator<U, alloc_> other;
Can we just replace "alloc_" with "A"? alloc_ is a typedef, which is
"typename std::allocator_traits<A>::template rebind_alloc<U>". Then, it
is "typename A::rebind<U>::other". Then, it is "A<U>", so the member
"other" can be "typedef default_init_allocator<U, A> other;".
--
Yao (齐尧)