Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #68420
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Bo Persson <bo@bo-persson.se> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: Why allocator<T>::rebind<U> was removed with C++20` |
| Date | Sat, 14 Sep 2019 22:49:47 +0200 |
| Lines | 33 |
| Message-ID | <gu523cFllipU1@mid.individual.net> (permalink) |
| References | <qlj9gc$d1h$1@news.albasani.net> <qljcn0$7a2$1@news.albasani.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net xQ435NwfmtSVcWz2a8PgGQYW7PHcloq7LWDbRvobvQfH76Fr2Q |
| Cancel-Lock | sha1:hKSWwrFrQx8gqAhUno5/FveZ4UQ= |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 |
| In-Reply-To | <qljcn0$7a2$1@news.albasani.net> |
| Content-Language | sv |
| Xref | csiph.com comp.lang.c++:68420 |
Show key headers only | View raw
On 2019-09-14 at 20:49, Bonita Montero wrote:
>> #include <memory>
>>
>> using my_allocator = std::allocator<char>;
>> using derived_allocator = my_allocator::rebind<int>::other;
>> my_allocator ma;
>> derived_allocator da( ma );
>
> I've got it; now it works like this:
>
> #include <memory>
>
> using my_allocator = std::allocator<char>;
> using derived_allocator =
> std::allocator_traits<my_allocator>::rebind_alloc<int>;
> my_allocator ma;
> derived_allocator da( ma );
>
> This unfortunately means that I've to specialize std::allocator_traits
> for my NUMA-allocator. That's more work than simply implementing rebind
> for my NUMA-allocator-class.
No, you don't really have to do all the extra work.
std::allocator_traits is supposed to be smart enough to use the
allocator's rebind member, if there is one. Or otherwise provide a default.
http://eel.is/c++draft/allocator.traits.types#11
Bo Persson
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Why allocator<T>::rebind<U> was removed with C++20` Bonita Montero <Bonita.Montero@gmail.com> - 2019-09-14 19:54 +0200
Re: Why allocator<T>::rebind<U> was removed with C++20` Bonita Montero <Bonita.Montero@gmail.com> - 2019-09-14 20:49 +0200
Re: Why allocator<T>::rebind<U> was removed with C++20` Bo Persson <bo@bo-persson.se> - 2019-09-14 22:49 +0200
Re: Why allocator<T>::rebind<U> was removed with C++20` Bonita Montero <Bonita.Montero@gmail.com> - 2019-09-15 03:00 +0200
csiph-web