Addresses of array elements as template non-type paramater
Hi there!
I can't understand why addresses of array elements cannot appear as non-type parameter in class template. I know that something like this:
1 2 3 4 5 6 7 8 9
|
int array[3] = {45, 57, 24};
//...
template <int *p>
class X { };
void fun()
{
X<&array[1]> xxx;
}
|
is dereferencing (in line 8), beacuse:
&array[1] = &(*(array+1))
But I don't know why compiler can't accept this expression:
X<array + 1> xxx;
Thank you.
Last edited on
Template values should be constants known at compile time
So... How do you explain something like this:
1 2 3 4 5 6
|
extern Foo foo;
//...
template <Foo* pointer>
class X { };
//...
X<&foo> x;
|
Compiler doesn't know foo's address yet :-/...
Topic archived. No new replies allowed.