KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Suppose I have a class where the copy constructor is private and not implemented (to make the object non-copyable) class NonCopyable { // whatever private: NonCopyable( const NonCopyable&); void operator=(const NonCopyable&); }; Now in some member function of the same class I write code that returns an object of that class: NonCopyable NonCopyable::Something() { return NonCopyable(); } which is a case when RVO could kick in. RVO still requires that a copy constructor is accessible. Since the possible call to the copy constructor is done from within the same class member function the copy constructor is accessible . So technically RVO is possible despite the fact that the intent was to prohibit using the copy constructor. Is RVO allowed in such cases?
Tags (comma-separated)
Save Edits
Cancel