Let's say that I have a template class declared as follows:
template< int *x > struct y { int *b; y() { b = x; }}
I need a template parameter as a constant memory address - this is inline code. If I try to create it this way: (gcc 4.8.1 compiler with -std = gnu ++ 11)
y< 1 > c;
I will get the error "could not convert the template argument '1' to 'int *'" and it is fine and in accordance with the standard. I understand.
My problem is that casting to pointers doesn't work either:
y< (int *)1 > d; y< reinterpret_cast<int *>(1) > e;
error: cannot convert template argument '1u' to 'int *'
in both cases. Why is this? The template argument has already been converted, right?
source share