Boost logo

Boost Users :

From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-03-28 11:42:24


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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net