OONumerics User :

From: Jean-Sebastien Mouret (oon-list_at_[hidden])
Date: 2005-12-13 18:29:29


Meng Xiangrui <mxr_at_[hidden]> writes:

> Hi,
>
> If I have declared a function
>
> double f(double);
>
> And I want to store the result into a new variable
>
> double p = f(2.0);
>
> But the compiler knows that f() will return a double type, so why not use
>
> define p = f(2.0); // Of course, "define" is just my word
>
> Is this achievable?

There is no support for this in the current C++ standard.
However a proposal to add an 'auto' keyword (same as your 'define')
to the language has been made :
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1721.pdf

Meanwhile you can workaround the problem by using functor typedefs as Russel suggested.
Maybe boost::any (http://www.boost.org/doc/html/any.html) can help you too.
It implements an assignable object that can contain anything.

Hope this helps.

-- 
js