I have problem to allocate the template size with a calculated number. when i set the value to a fixed number it runs with no problem
template<typename type>
static type high_exponents(const type a, const type e, const type mod) {
const type bits= log2(e); //<-----
std::bitset<bits> bit_set(e);
}
template<typename type>
static type high_exponents(const type a, const type e, const type mod) {
const type bits= 10000; // <-------
std::bitset<bits> bit_set(e);
}
this is the error i get
g++ -std=c++11 main.cpp -o output
In file included from rsa-crypt.h:3:0,
from main.cpp:2:
resources.h: In instantiation of 'static type resources::high_exponents(type, type, type) [with type = int]':
main.cpp:7:37: required from here
resources.h:43:24: error: the value of 'n' is not usable in a constant expression
std::bitset<n> bs;
^~
resources.h:42:29: note: 'n' was not initialized with a constant expression
const unsigned int n= (int) log2(e);
^
resources.h:43:24: note: in template argument for type 'unsigned int'
std::bitset<n> bs;
^~
make: *** [output] Error 1