A
Amit
Greetings.
How does one associate a integer variable to a non-type template parameter ?
Is there anyway of doing it in an easy way using partial specialization ? so
what I have is something to the effect of,
template<typename T, int N>
class X
{
bool operator()(T* p){
// do something;
}
}
template<typename T>
class X<T, 0>
{
bool operator()(T* p){
// do something;
}
}
template<typename T>
class X<T, 1>
{
bool operator()(T* p){
// do something;
}
}
and then using it like this,
template<typename T>
Myclass<T>::foo()
{
int val;
// evaluate val somehow..
X<T, val>()(someptr_p); //line 1
}
of course the compiler gives an error at line 1 as it expects a compile time
constant. So, is there anyway where one can evaluate val to something that
can be used
as a compile time constant.
Thanks.
How does one associate a integer variable to a non-type template parameter ?
Is there anyway of doing it in an easy way using partial specialization ? so
what I have is something to the effect of,
template<typename T, int N>
class X
{
bool operator()(T* p){
// do something;
}
}
template<typename T>
class X<T, 0>
{
bool operator()(T* p){
// do something;
}
}
template<typename T>
class X<T, 1>
{
bool operator()(T* p){
// do something;
}
}
and then using it like this,
template<typename T>
Myclass<T>::foo()
{
int val;
// evaluate val somehow..
X<T, val>()(someptr_p); //line 1
}
of course the compiler gives an error at line 1 as it expects a compile time
constant. So, is there anyway where one can evaluate val to something that
can be used
as a compile time constant.
Thanks.