having a variable act as a function call

I'd like to have a variable act as a function call. For example: Foo& getFoo(); foo; // really calls getFoo Is there a boost way to do this? Thanks, Noel -- NOTICE: If received in error, please destroy and notify sender. Sender does not waive confidentiality or privilege, and use is prohibited.

Noel Yap <Noel.Yap@morganstanley.com> writes:
I'd like to have a variable act as a function call. For example:
Foo& getFoo();
foo; // really calls getFoo
Is there a boost way to do this?
There's not even a C++ way to do it. If you have the luxury of assigning foo to another variable or passing it to a function, you can use implicit conversion operators to force a function call at that point. -- Dave Abrahams Boost Consulting www.boost-consulting.com

At Thursday 2004-02-12 07:43, you wrote:
I'd like to have a variable act as a function call. For example:
Foo& getFoo();
foo; // really calls getFoo
you're saying there is a function which reruns a reference to a foo and you want it called when you just say foo; you're throwing away the return? mayhaps you should re-think what you're trying to do
Is there a boost way to do this?
Thanks, Noel -- NOTICE: If received in error, please destroy and notify sender. Sender does not waive confidentiality or privilege, and use is prohibited. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Victor A. Wagner Jr. http://rudbek.com The five most dangerous words in the English language: "There oughta be a law"

"Victor A. Wagner, Jr." wrote:
At Thursday 2004-02-12 07:43, you wrote:
I'd like to have a variable act as a function call. For example:
Foo& getFoo();
foo; // really calls getFoo
you're saying there is a function which reruns a reference to a foo and you want it called when you just say foo; you're throwing away the return?
Not at all. I would like something that acts exactly like: # define foo getFoo() except that it must be codable from within another macro definition. It's not throwing away the return since: foo.bar(); should act exactly like: getFoo().bar(); Noel
participants (3)
-
David Abrahams
-
Noel Yap
-
Victor A. Wagner, Jr.