I just read this question, which raises for me another question:
Consider this class:
class Foo
{
public:
void setA(int a) { m_a = a; }
void setB(int b) { m_b = b; }
private:
int m_a, m_b;
};
Which could also be written using the "fluent interface" method:
class Foo
{
public:
Foo& setA(int a) { m_a = a; return *this; }
Foo& setB(int b) { m_b = b; return *this; }
private:
int m_a, m_b;
};
Now, if I write the following code snippet:
int main()
{
Foo foo;
foo.setA(1);
foo.setB(2);
}
Is there a performance difference induced by the additional return
directives if I use the second implementation of the class ?
Should I bother ? (My guess is "no")