Why does storing references (not pointers) in containers in C++ not work?

Containers store objects. References are not objects.

The C++11 specification clearly states (ยง23.2.1[container.requirements.general]/1):

Containers are objects that store other objects.

Leave a Comment