This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Dup status.

350. allocator<>::address

Section: [allocator.members], [allocator.requirements], [contents] Status: Dup Submitter: Nathan Myers Opened: 2001-10-25 Last modified: 2017-02-03

Priority: Not Prioritized

View all other issues in [allocator.members].

View all issues with Dup status.

Duplicate of: 634


See c++std-lib-9006 and c++std-lib-9007. This issue is taken verbatim from -9007.

The core language feature allowing definition of operator&() applied to any non-builtin type makes that operator often unsafe to use in implementing libraries, including the Standard Library. The result is that many library facilities fail for legal user code, such as the fragment

  class A { private: A* operator&(); };
  std::vector<A> aa;

  class B { };
  B* operator&(B&) { return 0; }
  std::vector<B> ba;

In particular, the requirements table for Allocator (Table 32) specifies no semantics at all for member address(), and allocator<>::address is defined in terms of unadorned operator &.

Proposed resolution:

In, Change the definition of allocator<>::address from:

Returns: &x


Returns: The value that the built in operator&(x) would return if not overloaded.

In 20.1.6, Table 32, add to the Notes column of the a.address(r) and a.address(s) lines, respectively:


In addition, in clause, add a statement:

The Standard Library does not apply operator& to any type for which operator& may be overloaded.


The LWG believes both examples are ill-formed. The contained type is required to be CopyConstructible ( [utility.arg.requirements]), and that includes the requirement that &t return the usual types and values. Since allocators are intended to be used in conjunction with containers, and since the CopyConstructible requirements appear to have been written to deal with the concerns of this issue, the LWG feels it is NAD unless someone can come up with a well-formed example exhibiting a problem.

It may well be that the CopyConstructible requirements are too restrictive and that either the container requirements or the CopyConstructive requirements should be relaxed, but that's a far larger issue. Marking this issue as "future" as a pointer to that larger issue.