A template for a container class like std::array<T> but with the following features.
More...
|
| array (size_t const length=0) |
| Construct an array of type T with managed storage. More...
|
|
| array (size_t const length, const T &value) |
| Construct an array of type T with managed storage. More...
|
|
template<class InputIterator > |
| array (InputIterator first, InputIterator last) |
| Construct an array of type T with managed storage. More...
|
|
| array (std::initializer_list< T > il) |
| Construct a vector of type T with managed storage. More...
|
|
| array (T *const buffer, size_t const length) |
| Construct an array of type T by attaching to an existing buffer. More...
|
|
template<std::size_t N> |
| array (std::array< T, N > &array) |
| Construct an array of type T by attaching to an existing buffer. More...
|
|
| array (std::vector< T > &array) |
| Construct an array of type T by attaching to an existing buffer. More...
|
|
| array (const array< T > &source) |
| array<T> Copy constructor More...
|
|
array< T > & | operator= (const array< T > ©) |
| Copy assignment operator. More...
|
|
virtual | ~array () |
|
T & | operator[] (size_t n) |
|
const T & | operator[] (size_t n) const |
|
template<class InputIterator > |
void | assign (InputIterator first, InputIterator last) |
| Assign new contents to the array, replacing its current contents. More...
|
|
void | assign (const T &value) |
| Assign new contents to the array, replacing its current contents. More...
|
|
void | assign (size_t n, const T &value) |
| Assign new contents to the array, replacing its current contents. More...
|
|
void | assign (std::initializer_list< T > il) |
| Assign new contents to the array, replacing its current contents. More...
|
|
T & | at (size_t n) |
|
const T & | at (size_t n) const |
|
T & | back () noexcept |
|
const T & | back () const noexcept |
|
bool | empty () const noexcept |
|
T & | front () noexcept |
|
const T & | front () const noexcept |
|
T * | data () noexcept |
|
const T * | data () const noexcept |
|
size_t | max_size () const noexcept |
|
size_t | size () const noexcept |
|
void | swap (array< T > &x) |
| Exchange the content of the container by the content of x, which is another object of the same type. More...
|
|
iterator | begin () noexcept |
|
const_iterator | begin () const noexcept |
|
const_iterator | cbegin () const noexcept |
|
iterator | end () noexcept |
|
const_iterator | end () const noexcept |
|
const_iterator | cend () const noexcept |
|
reverse_iterator | rbegin () noexcept |
|
const_reverse_iterator | rbegin () const noexcept |
|
const_reverse_iterator | crbegin () const noexcept |
|
reverse_iterator | rend () noexcept |
|
const_reverse_iterator | rend () const noexcept |
|
const_reverse_iterator | crend () const noexcept |
|
std::string | str (int verbosity=1, unsigned int columns=UINT_MAX) const |
| Generate a printable representation of the object. More...
|
|
template<typename T = double>
class molpro::array< T >
A template for a container class like std::array<T> but with the following features.
- Memory is provided from one of the following.
- allocated internally using molpro::allocator<T> which uses a managed stack
- attached to an existing raw array T[], std::vector<T> or std::array<T,N>, allowing one to optionally attach the container to existing data structures, and use the same syntax as std::array<T,N> to access it. In this case, the buffer is not deallocated on destruction of this object. It is the user's responsibility to ensure, in the case of std::vector<T> source, that the source is not subsequently resized or otherwise changed in a way that its data is moved.
- The interface is slightly different to std::array<T,N> in that the length is provided or implied in the constructor rather than as a template argument.
- The class is inheritable.
- A string representation function is provided for easy printing
Elements of the array are not constructed at allocation time, for reasons of efficiency, leading to a construction time that is approximately independent of the array size.
- Template Parameters
-
T | Type of the elements of the array. |
Example:
int main() {
{
for (size_t i=0; i<arr.size(); i++) arr[i]=100*i;
std::cout << "array element "<<*el<<std::endl;
}
int v[]={1,2,3,4,5,6};
{
*el=99;
}
std::cout << v[0] << std::endl;
return 0; }
A template for a container class like std::array<T> but with the following features.
Definition: memory.h:666
size_t memory_initialize(char *buffer, size_t max)
Definition: memory.h:104