Calling different functions depending on the template parameter c++
- by Noman Javed
I want to have something like that
class A
{
public:
Array& operator()()
{ . . . }
};
class B
{
public:
Element& operator[](int i)
{ ... }
};
template<class T>
class execute
{
public:
output_type = operator()(T& t)
{
if(T == A)
Array out = T()();
else
{
Array res;
for(int i=0 ; i < length; ++i)
a[i] = t[i];
}
}
};
There are two issues here
1. Meta-function replacing if-else in the execute operator()
2. Return type of execute operator()
Thanks in anticipation
Noman