David Peng Posted February 19 Report Posted February 19 Hi, I wonder any way to implement an array of sc_fifo with different depth. I wrote below demo code: sc_fifo<SomeClass> *s1; n=4; s1 = new sc_fifo<SomeClass>[n]; for (int i = 0; i < n; i++) { s1[n] = sc_fifo<SomeClass>(("FIFO_"+std::to_string(i)).c_str(), i*1024); } It failed that object of type sc_fifo<SomeClass> cannot be assigned because its copy assignment operator is implicitly deleted. Any suggestion? Or I have to use sc_vector? Thanks, David Quote
Eyck Posted February 19 Report Posted February 19 In your case you have to use the plcaement-new as described here: https://en.cppreference.com/w/cpp/language/new I would suggets to use C++14 constructs: std::array<std::unique_ptr<sc_fifo<SomeClass>>, 4> s1; for(size_t i = 0U; i < n; i++) { s1[i] = std::make_unique<sc_fifo<SomeClass>>("FIFO_"+std::to_string(i)).c_str(), i*1024); } This one manages the life time of your created objects... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.