Is it valid to have a std::pair of references ? In particular, are there issues with the assignment operator ? According to this link, there seems to be no special treatment with operator=, so default assignement operator will not be able to be generated.
I’d like to have a pair<T&, U&> and be able to assign to it another pair (of values or references) and have the pointed-to objects modified.
No, you cannot do this reliably in C++03, because the constructor of
pairtakes references toT, and creating a reference to a reference is not legal in C++03.Notice that I said “reliably”. Some common compilers still in use (for GCC, I tested GCC4.1, @Charles reported GCC4.4.4) do not allow forming a reference to a reference, but more recently do allow it as they implement reference collapsing (
T&isTifTis a reference type). If your code uses such things, you cannot rely on it to work on other compilers until you try it and see.It sounds like you want to use
boost::tuple<>