|
-
September 19th, 2011, 08:48 AM
#3
Re: Array of constant values as template parameter
No, that one did not work.
But this cool tidbit works with GCC. I tested it with GCC 4.5.2
Code:
#include <initializer_list>
template<const unsigned order>
struct orderN_math
{
static unsigned do_math(const std::initializer_list<unsigned>& coefficients)
{
return std::accumulate(coefficients.begin(), coefficients.end(), 0u);
}
};
const unsigned sum = orderN_math<3u>::do_math({ 1u, 3u, 3u, 1u });
VS2010 does not yet support <initializer_list>. But I don't really need it, as I'm using GCC.
Not exactly what I wanted, but a good start nonetheless.
At this time, I am investigating compiler efficiency for real-time embedded systems using solely pure language attributes and would prefer not to bind anything from boost into this investigation.
Thanks, Chris.
You're gonna go blind staring into that box all day.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|