If I have a function that returns a reference to an instance of a class that I do not have above its source, say list<int>:
list<int>& f();
I want to make sure that its value is assigned only to another link, for example:
list<int> &a_list = f();
If the user should have done this:
list<int> a_list = f();
I want this to be a compile-time error, as the user will only manipulate a copy of the list, not the original list (which is never intended for my application).
Is there a way to prevent the creation of a copy and assignment in the above (say, through some kind of "wrapper" class)?
Ideally, if you used some wrapper class, say wrapper<T>, I would like it to work for objects of any type T.
, , , , - private :
class MyClass {
public:
private:
MyClass( MyClass const& );
MyClass operator=( MyClass const& );
};
; , , , , std::list, - private.