Pointers will not work because queue- this is a local object that will be deleted at the end connect. Even using std::move, you still create a new object in a new memory location. He will simply try to use as much as possible from the "old" object.
, std::move, push_back , . , connect .
- queue . ++ 11:
#include <memory>
template<typename Item>
class Pipeline
{
[...]
void connect(OutputSide<Item> first, InputSide<Item> second)
{
auto queue = std::make_shared<Queue<Item>>();
first.setOutputQueue(queue);
second.setInputQueue(queue);
queues.push_back(queue);
}
[...]
std::vector<std::shared_ptr<Queue<Item>>> queues;
};