How can I have a pair with reference inside vector?
问题 I really need to make std::vector of std::pair with reference ( & ) inside, but it breaks inside the function when I try to push_back reference value. After debugging I discovered, that the address of reference is different from the address inside unique_ptr (but the value is the same). When I don't use (here the foo()) any function that insert into vector it's the value it refers to is correct, but the addresses still don't match. #include <iostream> #include <memory> #include <iterator>