Foundation of Algorithms in C++11, Volume 1(Third Edition): Using and Extending C++11, Boost And Beyond (Algocoders)

Author: Chandra Shekhar Kumar, Aditya Kant Sharma
This Month Stack Overflow 1


by anonymous   2019-01-13

A quoted text from Foundations of Algorithms in C++11, Volume 1, chap 4, p. 35 :

template <typename T> 
struct allocator 
   template <typename U>  
   using  rebind = allocator<U>; 

sample usage :

allocator<int>::rebind<char> x;

In The C++ Programming Language, 4th edition, section 34.4.1, p. 998, commenting the 'classical' rebind member in default allocator class :

template<typename U>
     struct rebind { using other = allocator<U>;};

Bjarne Stroustrup writes this:

The curious rebind template is an archaic alias. It should have been:

template<typename U>
using other = allocator<U>;

However, allocator was defined before such aliases were supported by C++.