Answer the question
In order to leave comments, you need to log in
C++, functor container?
Good afternoon!
There is the following task: it is necessary to implement a kind of pipeline that accepts some data as input, processes and outputs data of a different type. The trouble is that the stages of the pipeline accept and issue data of different types. In pseudocode, I see it like this:
class BaseStage
{
//Interface of stage
};
class Stage1: BaseStage
{
int operator()(SomeType data);
};
class Stage2: BaseStage
{
float operator()(SomeType data);
};
class Line
{
std::vector<BaseStage> _line;
std::vector<BaseStage>::iterator _it;
void func()
{
_it = _line.begin();
SomeType oldData, newData;
while (_it != _line.end())
{
newData = (*it)(oldData);
oldData = newData;
}
}
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question