class Sorter { public: Sorter(const Object ref) : ref_(ref) {} // other stuff private: const Object & ref_;};
See what the problem is? That's right, I ended up storing a reference to the parameter that was passed on the stack.
class Sorter { public: Sorter(const Object ref) : ref_(ref) {} // other stuff private: const Object & ref_;};