We propose a way to spell a universal template parameter kind. This would allow for a generic apply and other higher-order template metafunctions, and certain typetraits.
I wrote this text for P2667 which introduces buffered_allocator<T, SZ, Backing> where Backing is another allocator. For flat_maps I got this idea:
Another option, specific for flat_map and flatmultimap, would be to let them take a template template parameter for the allocator and use specializations of this template for Key and T alike. This reduces flexibility a bit but simplifies flat*map with custom allocators in general.
// Modified flat_map definition:
template<typename Key, typename T, typename Compare = less<Key>,
template<typename T> class Alloc = std::allocator>
class flat_map;
To use this with a buffered_allocator with size we need a helper type alias to bind
the size and Backing allocator, but leave the type unbound. This can't be done without
P1985 if flat_map expects to be able to specialize its template template parameter
like Alloc<Key> andAlloc<T>. Even with P1985 this can't be done without a helper struct template.
Maybe this can be written even more concisely in the future, but assigning an on the spot
created type alias template to a universal alias template seems scary.
Well there is a task for a new TMP-library based on UTP/UA. To be able to produce a type alias that flat_map can use requires binding the SZ and Backing parameters of buffered_allocator from template parameters... how hard can it be?
I wrote this text for P2667 which introduces
buffered_allocator<T, SZ, Backing>
where Backing is another allocator. For flat_maps I got this idea:Another option, specific for flat_map and flatmultimap, would be to let them take a template template parameter for the allocator and use specializations of this template for Key and T alike. This reduces flexibility a bit but simplifies flat*map with custom allocators in general.
To use this with a buffered_allocator with size we need a helper type alias to bind the size and Backing allocator, but leave the type unbound. This can't be done without P1985 if flat_map expects to be able to specialize its template template parameter like
Alloc<Key>
andAlloc<T>
. Even with P1985 this can't be done without a helper struct template.Maybe this can be written even more concisely in the future, but assigning an on the spot created type alias template to a universal alias template seems scary.
Well there is a task for a new TMP-library based on UTP/UA. To be able to produce a type alias that flat_map can use requires binding the SZ and Backing parameters of buffered_allocator from template parameters... how hard can it be?