As an example for this question I will use std::vector
.
Its definition from the documentation follows:
template<class T, class Allocator = std::allocator<T>>
class vector;
As expected, if T
- its type, the distributor should be shifted to the side T
.
In any case, the code below compiles without errors (at least using GCC) and runs :
#include<vector>
#include<memory>
#include<string>
struct S {
int i;
double d;
std::string s;
};
int main() {
std::allocator<int> alloc;
std::vector<S, std::allocator<int>> v{alloc};
v.push_back(S{});
}
Here I create a vector S using an int focused focus allocator.
? undefined? ?
, STL .
, , rebind
, std::list
, , .
, , , ( rebind
?), , .