T
toton
Hi,
I want to remember a compile time variable state, just to have some
typing convenience. I am not sure if I can do it using some typedef.
To give a short example,
I have an enum as,
enum dir_type{
dir_x,dir_y,dir_xd
};
and 2 specializations as,
template<dir_type>
dir_type o_dir();
template<>
dir_type o_dir<dir_x>(){
return dir_y;
}
template<>
dir_type o_dir<dir_y>(){
return dir_x;
}
now in a function I want to do,
template<dir_type dt>
void funct(){
std::cout<<dt<<std::endl;
dir_type od = o_dir<dt>(); /// what would be compile time equiv of
this line so than i can call next line?
dir_type d = o_dir<od>();
}
Now for the commented line, I want a compile time typedef , so that od
is a name rather than a runtime state, and I can call the next line.
This is just to remove repetitive writing of o_dir<dt> , in several
places when i can simply write od.
thanks
abir
I want to remember a compile time variable state, just to have some
typing convenience. I am not sure if I can do it using some typedef.
To give a short example,
I have an enum as,
enum dir_type{
dir_x,dir_y,dir_xd
};
and 2 specializations as,
template<dir_type>
dir_type o_dir();
template<>
dir_type o_dir<dir_x>(){
return dir_y;
}
template<>
dir_type o_dir<dir_y>(){
return dir_x;
}
now in a function I want to do,
template<dir_type dt>
void funct(){
std::cout<<dt<<std::endl;
dir_type od = o_dir<dt>(); /// what would be compile time equiv of
this line so than i can call next line?
dir_type d = o_dir<od>();
}
Now for the commented line, I want a compile time typedef , so that od
is a name rather than a runtime state, and I can call the next line.
This is just to remove repetitive writing of o_dir<dt> , in several
places when i can simply write od.
thanks
abir