OONumerics User : |
From: Sohail Somani (s.somani_at_[hidden])
Date: 2005-12-13 17:02:26
> -----Original Message-----
> From: oon-list-bounces_at_[hidden]
> [mailto:oon-list-bounces_at_[hidden]] On Behalf Of Russell Smiley
> Sent: Tuesday, December 13, 2005 12:36 PM
> To: oon-list_at_[hidden]
> Subject: Re: [oon-list] Default type declaration achievable?
>
>
> > -----Original Message-----
> > From: oon-list-bounces_at_[hidden] On Behalf Of Roman Krylov
> > To: oon-list_at_[hidden]
> > Subject: Re: [oon-list] Default type declaration achievable?
> >
> >
> > If you want to use 'same_type_as_f_return_type' you can use
> >
> > typedef double f_type
> > f_type f(double);
> > f_type p = f(...);
> > and if you want to change f's type in future - you'll change
> > only 1st line. Or was it the blame to language(meant C or C++
> > ?) not having ability to
> > express, for instance 'f::ret_type p = ...',
>
> Now that's an interesting idea...
>
> I guess you could achieve this by using a static member
> function of a "function container" class:
>
> class fcn_container
> {
> public:
> typedef double ret_type;
> typedef int arg1_type;
> typedef char arg2_type;
>
> static ret_type f (arg1_type, arg2_type);
> };
>
> You could then call the function with:
>
> fcn_container::arg1_type arg1 = 3.14;
> fcn_container::arg2_type arg2 = 'a';
> fcn_container::ret_type p = fcn_container::f(arg1, arg2);
>
> I guess this makes the class fcn_container into a kind of
> namespace, so you could just as easily use namespaces to
> achieve the same result. Not sure if there might be some
> advantage or disadvantage to using the static member function
> approach over namespaces.
>
I believe the newest standard has a proposal so that this is possible:
template<typename Ret,typename Arg1, typename Arg2>
Ret func(Arg1 a, Arg2 b);
auto myretval = func(a,b);
Submitted by none other than bjarne iirc.
:)