By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,605 Members | 1,488 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,605 IT Pros & Developers. It's quick & easy.

class encapsulating reference

P: n/a
Hello,

The class TRefByValue in the Symbian OS API
encapsulates a reference inside a class so that
it can be passed by value to functions. But why
would we want this? After all, if a function needs
to take a reference parameter, why code the
function to take TRefByValue as a value
parameter instead? I don't see any
advantage to this.

http://www.symbian.com/developer/tec...alueClass.html

Comments appreciated,

Thanks,

JG

Nov 14 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a

John Goche wrote:
Hello,

The class TRefByValue in the Symbian OS API
encapsulates a reference inside a class so that
it can be passed by value to functions. But why
would we want this? After all, if a function needs
to take a reference parameter, why code the
function to take TRefByValue as a value
parameter instead? I don't see any
advantage to this.

http://www.symbian.com/developer/tec...alueClass.html

Comments appreciated,

Thanks,

JG
from boost::ref documentation:

"The purpose of boost::reference_wrapper<Tis to contain
a reference to an object of type T. It is primarily used to
"feed" references to function templates (algorithms)
that take their parameter by value."

Nov 14 '06 #2

P: n/a
dasjotre wrote:
John Goche wrote:
Hello,

The class TRefByValue in the Symbian OS API
encapsulates a reference inside a class so that
it can be passed by value to functions. But why
would we want this? After all, if a function needs
to take a reference parameter, why code the
function to take TRefByValue as a value
parameter instead? I don't see any
advantage to this.

http://www.symbian.com/developer/tec...alueClass.html

Comments appreciated,

Thanks,

JG

from boost::ref documentation:

"The purpose of boost::reference_wrapper<Tis to contain
a reference to an object of type T. It is primarily used to
"feed" references to function templates (algorithms)
that take their parameter by value."
Thank you dasjotre for your reply.

However, I do not see the point in the definition of RTest::Printf for
example. See

http://www.symbian.com/developer/tec...3aPrintf%28%29

Here the argument to Printf is not a templated parameter
passed by value as in the boost example you mentioned.
So why is the TDesC string parameter passed in this way?

Furthermore, what is the meaning of

operator &()

as found in TRefByValue? What does this do?

Thanks,

JG

Nov 20 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.