M
mathieu
Hi,
Consider the following (*). Is there a way to rewrite it so that it
remains convenient (N is being recomputed when array v is modified)
*and* compiles
Thanks,
-Mathieu
(*)
template <typename T, unsigned int N>
struct Functor
{
T values[N];
};
int main()
{
const double v[] = {0, 1, 4, 9, 16, 25, 36 };
const unsigned int N = sizeof(v) / sizeof(v[0]);
Functor<double,N> f = v; // will not compile
//Functor<double,7> f = { {0, 1, 4, 9, 16, 25, 36 } }; // need to
compute 7 by hand...
return 0;
}
Consider the following (*). Is there a way to rewrite it so that it
remains convenient (N is being recomputed when array v is modified)
*and* compiles
Thanks,
-Mathieu
(*)
template <typename T, unsigned int N>
struct Functor
{
T values[N];
};
int main()
{
const double v[] = {0, 1, 4, 9, 16, 25, 36 };
const unsigned int N = sizeof(v) / sizeof(v[0]);
Functor<double,N> f = v; // will not compile
//Functor<double,7> f = { {0, 1, 4, 9, 16, 25, 36 } }; // need to
compute 7 by hand...
return 0;
}