Const references in std::vector elements
The vector
elements must be assignable. From section 23.2.4 Class template vector of the C++ standard:
...the stored object shall meet the requirements of Assignable.
You may want to check
std::reference_wrapper
available with C++11
No, because you can't assign to a const reference and the STL containers make use of assignment for moving items around.
You're better using a shared_ptr
(boost::
or std::
depending on your environment) or a raw pointer.