I'm struggling with the following situation.
#include "systemc.h"
template<int maxval>
class Foo {
/* Error: calls to constructors and functions cannot be part of a constant expression */
sc_uint<int(log2(double(maxval)))> a;
...
};
int main() {
Foo<10> foo;
...
return 0;
}
As you can observe above, the templated class 'Foo' has the template parameter 'maxval'. 'Foo' also holds a member, again a templated class, that uses the template parameter 'maxval' together with the function 'log2' in its template arguments for instantiation. However, the depicted code will not work since e.g. function calls cannot be part of constant expressions. Do you see any possibility to evaluate e.g. log2(maxval) during compile time and to use the result for further template arguments inside 'Foo'?
Thanks for your help. (I'm using GCC 4.1.2)