KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Before someone jumps and says Profile before optimize! , this is simply a curiosity question and stems from this original question . If I am returning by reference the same object, would that get optimized away if not used? For example, I have a Vector<> that has various mathematical functions (assume I am not using operator overloading). Two ways of writing it: inline void Vector::Add(const Vector& in) // Adds incoming vector to this vector OR inline Vector& Vector::Add(const Vector& in) // Adds incoming vector to this vector and returns a reference to this vector Now if Add() is used without utilizing the return value, will the compiler simply throw away the return altogether and the function becomes as if it has no return value to begin with? And what if it is NOT inlined ?
Tags (comma-separated)
Save Edits
Cancel