Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is an old version of boost. Click here for the latest version's documentation home page.

Array Storage

Array Adaptor

Description

The templated class carray_adaptor<T> implements a storage array using a pointer to an existing memory buffer (a C array for example). The storage specified array size must never exceed the size of the memory buffer.

carray_adaptor defines size_type as size_t and difference_type as std::ptrdiff_t.

Example

#include <boost/numeric/ublas/storage.hpp>

int main () {
    using namespace boost::numeric::ublas;
    double aarray[10];
    carray_adaptor<double> a (aarray, 3);
    for (unsigned i = 0; i < a.size (); ++ i) {
        a [i] = i;
        std::cout << a [i] << std::endl;
    }
}

Definition

Defined in the header storage.hpp.

Template parameters

Parameter Description Default
T The type of object stored in the array.

Model of

Storage but NOT Copy Constructable

Type requirements

None, except for those imposed by the requirements of Storage.

Public base classes

None.

Members

Member Where defined Description
value_typeContainer
pointerContainerDefined as value_type*
const_pointerContainerDefined as const value_type*
referenceContainerDefined as value_type&
const_referenceContainerDefined as const value_type&
size_typeContainerDefined as Alloc::size_type
difference_typeContainerDefined as Alloc::difference_type
iteratorContainerDefined as pointer
const_iteratorContainerDefined as const_pointer
revere_iteratorContainerDefined as std::reverse_iterator<iterator>
const_revere_iteratorContainerDefined as std::reverse_iterator<const_iterator>
carray_adaptor () Storage Creates an carray_adaptor that holds zero elements.
carray_adaptor (size_type size) Storage The size-constructor is undefined. A carray_adaptor cannot be constructed like this as a memory buffer cannot be specifed in this context.
carray_adaptor (size_type size, const T& init) Storage The fill-constructor is undefined. A carray_adaptor cannot be constructed like this as a memory buffer cannot be specifed in this context.
bounded_array (size_type size, pointer data) Storage Creates a uninitialized bounded_array that holds size elements from the memory buffer data. All the elements are default constructed.
bounded_array (size_type size, pointer data, const T& init) Storage Creates an initialized bounded_array that holds size elements from the memory buffer data. All the elements are constructed from the init value.
carray_adaptor (const carray_adaptor &c) Container The copy constructor is private and undefined. A carray_adaptor cannot be constructed like this as a memory buffer cannot be specifed in this context.
~carray_adaptor () Container Deallocates the carray_adaptor itself.
void resize (size_type size) Storage Reallocates a carray_adaptor to hold size elements.
void resize (size_type size, const T& t) Storage Reallocates a carray_adaptor to hold size elements.
void resize (size_type size pointer data) Storage Reallocates a carray_adaptor to hold size elements.
void resize (size_type size pointer data, const T& t) Storage Reallocates a carray_adaptor to hold size elements.
size_type size () const Container Returns the size of the carray_adaptor.
const_reference operator [] (size_type i) const Container Returns a const reference of the i -th element.
reference operator [] (size_type i) Container Returns a reference of the i-th element.
carray_adaptor &operator = (const carray_adaptor &a) Container The assignment operator.
carray_adaptor &assign_temporary (carray_adaptor &a) Assigns a temporary. May change the array a.
void swap (carray_adaptor &a) Container Swaps the contents of the arrays.
const_iterator begin () const Container Returns a const_iterator pointing to the beginning of the carray_adaptor.
const_iterator end () const Container Returns a const_iterator pointing to the end of the carray_adaptor.
iterator begin () Container Returns a iterator pointing to the beginning of the carray_adaptor.
iterator end () Container Returns a iterator pointing to the end of the carray_adaptor.
const_reverse_iterator rbegin () const Reversible Container Returns a const_reverse_iterator pointing to the beginning of the reversed carray_adaptor.
const_reverse_iterator rend () const Reversible Container Returns a const_reverse_iterator pointing to the end of the reversed carray_adaptor.
reverse_iterator rbegin () Reversible Container Returns a reverse_iterator pointing to the beginning of the reversed carray_adaptor.
reverse_iterator rend () Reversible Container Returns a reverse_iterator pointing to the end of the reversed carray_adaptor.