kk8
asked on
template related question
Hi,
How do you generalize this module to work for any integer value instead of 2?
std::string ToBinString(unsigned long val, int ndigits ){
const std::bitset<2> bs(val); //Generalize this - use any integer instead of 2
const std::string s(bs.to_string());
return s;
}
Thank you.
How do you generalize this module to work for any integer value instead of 2?
std::string ToBinString(unsigned long val, int ndigits ){
const std::bitset<2> bs(val); //Generalize this - use any integer instead of 2
const std::string s(bs.to_string());
return s;
}
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
template <size_t T>
instead of
template <class T>
Did not realize i could use size_t as a template, silly me.