P
Peter
Posting this again, since google-groups may have swallowed it
earlier...
What is the use of the auto keyword for function return types,
if I anway have to declare the type by hand after the function header?
In this case I've could also have written the return type up front
using the template types of the variables instead of variable names.
Currently i'm writing all the code to be included in the function
using macros,
with the macro names matching the variable names.
I do this since the code is needed twice
-- once for the return type determination and once for the actual
function body
(this is some simple example demonstrating my approach.
Imagine much bigger functions):
Can somebody come up with a simpler approach?
template<typename T0, typename T1>
auto getSomething(const T0 &_r0, const T1&_r1)
#define _a (_r0 + _r1)
#define _b (_a*_a)
#define _c (_b*_a)
-> decltype(_c)
{
const auto a(_a);
#undef _a
#define _a a
const auto b(_b);
#undef _b
#define _b b
const auto c(_c);
#undef _c
#undef _b
#undef _a
return c;
}
earlier...
What is the use of the auto keyword for function return types,
if I anway have to declare the type by hand after the function header?
In this case I've could also have written the return type up front
using the template types of the variables instead of variable names.
Currently i'm writing all the code to be included in the function
using macros,
with the macro names matching the variable names.
I do this since the code is needed twice
-- once for the return type determination and once for the actual
function body
(this is some simple example demonstrating my approach.
Imagine much bigger functions):
Can somebody come up with a simpler approach?
template<typename T0, typename T1>
auto getSomething(const T0 &_r0, const T1&_r1)
#define _a (_r0 + _r1)
#define _b (_a*_a)
#define _c (_b*_a)
-> decltype(_c)
{
const auto a(_a);
#undef _a
#define _a a
const auto b(_b);
#undef _b
#define _b b
const auto c(_c);
#undef _c
#undef _b
#undef _a
return c;
}