驚いたことに、std::vector::get_allocator()
コピー不可のアロケータを使用しようとするとエラーが発生しました。std::vector::get_allocator()
参照ではなく値で返すのはなぜですか?
template<typename T>
class nc_allocator {
public:
using value_type = T;
nc_allocator(nc_allocator const&) = delete;
nc_allocator& operator=(nc_allocator const&) = delete;
// Other required members.
};
std::vector<int, nc_allocator<int>> v;
// boom: use of deleted function
// 'nc_allocator<T>::nc_allocator(const nc_allocator<T>&) [with T = int]'
v.get_allocator();