This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Introduce gdb::byte_vector, add allocator that default-initializes


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 (齐尧)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]