Mail Archives: djgpp/2000/03/08/03:49:49
On Tue, 7 Mar 2000, Robin Johnson wrote:
> Hi,
>
> I need some help trying to convert all the elements of an STL vector array <int>
> to an *int array, for use with the Allegro polygon function.
> I am currently using libgpp for the STL. I had some code that worked with TC and
> most real mode compilers, using a few assembler shortcuts that of course don't
> work in protected mode. Anybody willing to lend a hand?
>
> source: vector <int> v_list;
> dest: *int p_list;
>
Simple example:
#include <algorithm>
#include <vector>
#include <iterator>
template <class T>
T * to_array (vector<T> & from)
{
T * ret = new T [from.size()];
copy (from.begin(), frome.end(), ret);
return ret;
}
Don't forget to free returned array after use.
- Raw text -