Guys, reffering to last post I’m trying to output data while template is instantiated
template <unsigned long N>
struct binary
{
std::cout << N;//<---------------------------------I'M TRYING HERE
static unsigned const value
= binary<N/10>::value << 1 // prepend higher bits
| N%10; // to lowest bit
but I’m getting an error:
‘Error 2 error C2886: ‘std::cout’ : symbol cannot be used in a member using- declaration ‘
Thanks for help
P.S.
And could anyone explain why actually I can’t do that?
Template instantiation happens at compile-time. You can’t output anything at compile-time.
All you can do is calculate the value at compile-time and the output it at run-time (i.e. inside a function).