I have a custom class producer
which inherits from SystemC class sc_module
:
class producer: public sc_module {
public:
int counter;
sc_in<bool> clock;
sc_out<msg> out;
int speed;
producer(sc_module_name name, int speed) :
sc_module(name),
speed(speed)
{
SC_HAS_PROCESS(producer);
SC_METHOD(produce);
sensitive << clock.pos();
counter = 0;
}
void produce() {
...
}
};
Later in the SystemC sc_main
-class I want to put a bunch of objects in a std::vector<producer>
:
std::vector<producer> producers;
for(int i = 0; i < numIn; i++){
producers.at(i) = producer("Producer " + i, genSpeed); // <- Here the error occurs
}
And here is the compiler error:
error: use of deleted function ‘producer& producer::operator=(producer&&)’
producers.at(i) = producer("Producer " + i, genSpeed);
^
dist.cpp:103:7: note: ‘producer& producer::operator=(producer&&)’ is implicitly deleted because the default definition would be ill-formed:
class producer: public sc_module {
^~~~~~~~
Why does the error occur? How can I fix it?
I our final solution we used
std::shared_ptr
andstd::vector
: