llvm-mos-sdk
soa::Ptr< T > Class Template Reference

#include <soa.h>

Detailed Description

template<typename T>
class soa::Ptr< T >

Pointer to an array element.

This proxy provides access to the contents of a specific array element. If the type is arithmetic or a pointer, it can be used in numeric expressions with the full range of operators, including the various assignment operators. If it is a struct, by default the struct type is opaque. It's members are not directly accessible, and the struct can only be read or written as a whole. A specialization can be generated to allow for member access using the soa-struct.inc header; see that header for details.

Pointers should not be stored more than temporarily, and they should not be used as arguments to functions. This may cause them to acually take on their logical representation at runtime (an array of pointers, one per byte), which is typically worse than using a regular C-style array.

A number of helpers are added to make the type more ergonomic, that is, more like a reference. First, the type is implicitly convertable to and from the wrapped type, the wrapped type is also directly assignable to the pointer. Arithmetic assignment operators are implemented in terms of binary arithmetic on the wrapped type wherever possible. If the wrapped type is a pointer, the arrow operator functions on the wrapped type. Otherwise, the arrow operator provides access to the wrapped type itself. This operates by making a copy of the value and writing it back if modified, so take care when using this.


The documentation for this class was generated from the following file: