cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

gentiradentes
Journeyman III

Any way to create an array of streams?

I'm trying to create a dynamically allocated array of streams, but there is no default constructor for Brook's stream object, so the typical syntax for a simple pointer array doesn't work.

 

> Stream<int>* streams = new Stream<int>[numStreams]; //Needs a ctor

 

I also tried a vector, but that didn't work either. Is there any way to create an array of streams? If not, is there any other way to dynamically allocate an arbitrary number of streams?

 

Thanks.

0 Likes
3 Replies
Raistmer
Adept II

I suppose you need array of similar streams. That is, all streams will have same dimension and same length.
Maybe it's worth to try use Stream constructor for single stream allocation?
Smth like this:
unsigned int size=STREAM_SIZE;
brook::Stream< int > (*sarray)[sarray_len];
for(int i=0;i < sarray_len; i++ )
sarray[ i ]=new brook::Stream< int >(1,&size);

0 Likes

This sounds perfect, an array of similar streams works great for me. All I need is for the number of streams allocated to be dynamic. I'll try this out when I get the chance, thanks a lot!

 

EDIT: This actually doesn't work, the size of this style of array needs to be given as a constant, I need it to be dynamic. Is there any other way?

0 Likes

You can dynamically allocate that array-

brook::Stream< int >** sarray = new brook::Stream< int >*[sarray_len];

0 Likes