util::Buffer< T, size > Class Template Reference
A ranged checked array.
More...
#include <util/buffer.h>
List of all members.
Public Member Functions |
| Buffer (const T &val=T()) |
| Constructor.
|
T * | c_data () |
| Return the data as a C-style array.
|
T & | operator[] (unsigned int i) throw (std::out_of_range) |
| Index operator.
|
virtual | ~Buffer () |
| Destructor.
|
Detailed Description
template<class T, unsigned int size>
class util::Buffer< T, size >
A ranged checked array.
- Parameters:
-
| T | The type to store. |
| size | The size of the array. |
Definition at line 20 of file buffer.h.
Constructor & Destructor Documentation
template<class T , unsigned int size>
Constructor.
- Parameters:
-
| val | The inital value for the elements of Buffer. |
Definition at line 72 of file buffer.h.
00072 {
00073 for (unsigned int i = 0; i < size; i++) data[i] = val;
00074 }
template<class T , unsigned int size>
Destructor.
Definition at line 78 of file buffer.h.
Member Function Documentation
template<class T , unsigned int size>
Return the data as a C-style array.
This function allows the data in Buffer to be passed as a pointer to a C-style array. Like all C-style arrays, it should be used with caution as access is not checked.
Definition at line 101 of file buffer.h.
00101 {
00102 return data;
00103 }
template<class T , unsigned int size>
T & util::Buffer< T, size >::operator[] |
( |
unsigned int |
i |
) |
throw (std::out_of_range) [inline] |
Index operator.
- Parameters:
-
| i | The index to reference. |
The index operator is range checked. If i is out of range, std::out_of_range is thrown.
Definition at line 88 of file buffer.h.
00088 {
00089 if (i < size) return data[i];
00090 else throw std::out_of_range("Buffer index is out of range.");
00091 }
The documentation for this class was generated from the following file: