ACE_Array增加越界访问控制,以下为测试代码。
// sctpserver.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "ace/Containers.h"
int _tmain(int argc, _TCHAR* argv[])
{
ACE_Array<int> arr(10);
//set value
for(int index=0; index<10; index++)
{
//the first parameter is value, and the second paramter is index
int value = index * 10;
arr.set(value, index);
}
//get value
for(int index=0; index<10; index++)
{
int value = 0;
arr.get(value, index);
printf("%d\n", value);
}
int value = 0;
int index = 100;
printf("illegal get value = %d\n", arr.get(value, index));
//get size of array
printf("size=%d\n", arr.size());
//整体赋值操作
ACE_Array<int> copy;
copy = arr;
//使用跌代器访问
ACE_Array<int>::ITERATOR iter(copy);
while (!iter.done ())
{
int* data;
iter.next(data);
printf("%d\n",*data);
iter.advance ();
}
getchar();
return 0;
}