'C++ template function, how to handle case where a template types does not have a specific method
In C++, I have a template function which takes an operation type as the type.
The types are operations types in a neural network for example a convolution, depthwise or a MaxPool.
But the types have different methods that can be called on them.
For example. Only convolution or depthwise convolution have a method called filter(). MaxPool type does not a method called filter().
Is there anyway to enable compilation with such a case or should I not be using a template?
template <class OpType>
void Manager::createTensor(OpType& operation) const {
const auto filterShape = getShape(operation.filter());
}
When I try to compile this I get error: ‘class MaxPoolOp’ has no member named ‘filter()
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
