Boost study#4
- 55. virtual BOOL IsDead( VOID ){ return FALSE };
2011 2 26
- 88. Array()
virtual ‾Array()
void alloc(unsigned int size);
void release();
void setFuncValid(FuncValid i);
FuncValid funcValid();
void setFuncEqual(FuncEqual i);
FuncEqual funcEqual();
void setFuncSort(FuncSort i);
FuncSort funcSort();
bool valid();
unsigned int size();
T &operator[](unsigned int index);
T &operator[](int index);
Array<T> &operator=(const Array<T> &i);
T *ptr();
void push(T&v);
void pop(T &v);
T *find(T &v);
T *findInvalid();
void sort();
bool validAssert();
unsigned int count(FuncValid func);
void clear();
void fill(T i);
2011 2 26
- 110. typedef eastl::list<int, fixed_allocator> IntList;
typedef IntList::node_type IntListNode;
IntListNode buffer[200];
IntList intList;
intList.get_allocator().init(
buffer,
sizeof(buffer),
sizeof(IntListNode),
__alignof(IntListNode)
);
2011 2 26
- 113. template <typename T,
size_t nodeCount,
bool bEnableOverflow = true,
typename Allocator = EASTLAllocatorType>
class fixed_vector
T =
nodeCount =
bEnableOverflow =
Allocator =
bEnableOverflow ture
2011 2 26
- 114. Example usage:
fixed_vector<Widget, 128, true> fixedVector;
fixedVector.push_back(Widget());
fixedVector.resize(200);
fixedVector.clear();
2011 2 26
- 142. // tuple!!
#include <boost/tuple/tuple.hpp>
class HandleBase;
boost::tuple<unsigned long, unsigned long>
RegisterHandle(void* object);
void UnregisterHandle(HandleBase handle);
class HandleBase
{
public:
// valid
inline bool isValid() const
2011 2 26
- 143. template <class T>
class Handle : public HandleBase
{
public:
Handle(unsigned long id, unsigned long index)
: HandleBase(id, index)
{
}
...
//
T* operator->() const
2011 2 26