lundi 31 octobre 2016

Does being std::move'd affect references?

I'm trying to make sense of some code I'm looking at, and one thing that I noticed is that one class keeps a reference to this one object in a reference member, while some other code move constructs it.

I'm curious how those play together. Is a reference member still valid if the underlying object is the source (or target) of a std::move operation?

How about if I happen to know that the underlying object has all its move operators custom defined to just std::move all its members? Presumably in that case the reference to it is valid when the source object being referenced is valid, and not valid when it isn't, right?

Aucun commentaire:

Enregistrer un commentaire