AMDG Ovanes Markarian wrote:
What do you think how this allocator will allocate the number of these element? Actually in any possible way. It can use new[] or new char[sizeof(T)*NumElems] or use an own mem-manager. And the worse thing you can't make allocator friend of your class, since users of containers can pass their own allocators.
It can't use new[] because new[] constructs the elements immediately.
And despite all enumerated facts you will fail to compile, since the function address will fail to return the pointer to x, because it is prohibited in your case.
Yep. This a serious problem. overloading operator& can cause generic code to break randomly, because most people assume that &x will work. (And those that don't probably circumvent your defenses by using boost::addressof, anyway.) In Christ, Steven Watanabe