A template class that references a constant one-dimensional "array-like" object.
More...
|
| ConstArray (const Array &data, size_t size) |
| Constructs a new wrapper object for the given array-like object. More...
|
|
| ConstArray (const ConstArray< Array > &)=default |
| Constructs a new wrapper for the same underlying array as the given wrapper. More...
|
|
ConstArray< Array > & | operator= (const ConstArray< Array > &)=default |
| Sets this to wrap the same underlying array as the given wrapper. More...
|
|
size_t | size () const |
| Return the number of elements in this array. More...
|
|
auto | getItem (size_t index) const |
| Returns the array element at the given index. More...
|
|
std::ostream & | writeText (std::ostream &out) const |
| Writes a string representation of this array, including all of its elements, to the given output stream. More...
|
|
template<typename Array>
class regina::python::ConstArray< Array >
A template class that references a constant one-dimensional "array-like" object.
This can be used with plain C-style arrays, or can also be used with constant "array-like" objects such as Perm<4>::S4, which behave like arrays but in fact compute their values on the fly.
The requirements for the type Array are:
- It must provide a square bracket operator, which returns its results by value (not by reference or pointer). This means that we do not need to specify any return value policy.
- An object of type Array is both cheap and safe to copy by value. For example, this is true for Perm<4>::S4 which is a struct with no data members. It is also true for C-style arrays, since what is actually copied is a pointer, not the array contents.
In Python, the usual list operator [] can be used to access the elements of the array. Range checking is performed on any index that is passed.
For each different template parameter, the corresponding ConstArray class must be wrapped in Python before the first object of this class is wrapped. This wrapping is performed by calling wrapClass().
- Precondition
- The output operator << is defined for the objects contained in this array (i.e., for the return type of the square bracket operator).