Questions tagged [reference-wrapper]
107 questions
-2
votes
2 answers
Reference_wrapper: Push_back works but not assigning
In the following code, push_back() a std::ref into a std::vector> works well however, assigning a std::ref to a reference_wrapper does not work. Why?
#include
#include
#include
using…

Shibli
- 5,879
- 13
- 62
- 126
-3
votes
2 answers
Return value of non-initialized reference_wrapper
Where does reference_wrapper point to when I resize() the vector below? Is this an undefined behavior? What should I do for safety?
std::vector < std::reference_wrapper > vec;
vec.resize(10);

Shibli
- 5,879
- 13
- 62
- 126