I have a .h
file with all my templates in it and a .cpp
file with my main.
Part of .h
templates:
template<int N, int P>
struct BOUND {
static inline int eval(int v) {
//...
return 1;
};
};
template<class K>
struct VAL_x {
static inline int eval(int v) {
//...
return 1;
};
};
template<int L, class K>
struct LIT {
static inline int eval(int v) {
//...
return 1;
};
};
template<class A, class B, class K>
struct ADD {
static inline int comp_b(int v){
// HERE check if class A is LIT or VAL_x
//...
return 2;
};
};
Here is how I call in my main()
this template:
int main() {
typedef ADD<VAL_x<BOUND<2,3> >, LIT<2, BOUND<2,3> >, BOUND<2,3> > FORM;
FORM exec_form;
int y = 2;
int bounds = exec_form.comp_b(y);
return 0;
}
How can I know in ADD::comp()
function of my struct
, if an argument that was passed is instance of a specific class (e.g. LIT<>
)? Those arguments can be passed in any order (e.g all arguments could be LIT
, or only the second one)
NOTE: there are also other structs apart from VAL_x
, LIT
, BOUND
and ADD
.