...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::compute::array — A fixed-size container.
// In header: <boost/compute/container/array.hpp> template<typename T, std::size_t N> class array { public: // types typedef T value_type; typedef std::size_t size_type; typedef ptrdiff_t difference_type; typedef unspecified reference; typedef unspecified const_reference; typedef T * pointer; typedef const T * const_pointer; typedef buffer_iterator< T > iterator; typedef buffer_iterator< T > const_iterator; typedef std::reverse_iterator< iterator > reverse_iterator; typedef std::reverse_iterator< const_iterator > const_reverse_iterator; enum @0 { static_size = = N }; // construct/copy/destruct explicit array(const context & = system::default_context()); array(const array< T, N > &); array(const boost::array< T, N > &, const context & = system::default_context()); array(const array< T, N > &, const command_queue &); array< T, N > & operator=(const array< T, N > &); array< T, N > & operator=(const boost::array< T, N > &); ~array(); // public member functions iterator begin(); const_iterator begin() const; const_iterator cbegin() const; iterator end(); const_iterator end() const; const_iterator cend() const; reverse_iterator rbegin(); const_reverse_iterator rbegin() const; const_reverse_iterator crbegin() const; reverse_iterator rend(); const_reverse_iterator rend() const; const_reverse_iterator crend() const; size_type size() const; bool empty() const; size_type max_size() const; reference operator[](size_type); const_reference operator[](size_type) const; reference at(size_type); const_reference at(size_type) const; reference front(); const_reference front() const; reference back(); const_reference back() const; void fill(const value_type &, const command_queue &); void swap(array< T, N > &, const command_queue &); void fill(const value_type &); void swap(array< T, N > &); const buffer & get_buffer() const; // private member functions command_queue default_queue() const; };
The array container is very similar to the vector container except its size is fixed at compile-time rather than being dynamically resizable at run-time.
For example, to create a fixed-size array with eight values on the device:
boost::compute::array<int, 8> values(context);
The Boost.Compute array
class provides a STL-like API and is modeled after the std::array
class from the C++ standard library.
See Also:
array
public
construct/copy/destructexplicit array(const context & context = system::default_context());
array(const array< T, N > & other);
array(const boost::array< T, N > & array, const context & context = system::default_context());
array(const array< T, N > & other, const command_queue & queue);
array< T, N > & operator=(const array< T, N > & other);
array< T, N > & operator=(const boost::array< T, N > & array);
~array();
array
public member functionsiterator begin();
const_iterator begin() const;
const_iterator cbegin() const;
iterator end();
const_iterator end() const;
const_iterator cend() const;
reverse_iterator rbegin();
const_reverse_iterator rbegin() const;
const_reverse_iterator crbegin() const;
reverse_iterator rend();
const_reverse_iterator rend() const;
const_reverse_iterator crend() const;
size_type size() const;
bool empty() const;
size_type max_size() const;
reference operator[](size_type index);
const_reference operator[](size_type index) const;
reference at(size_type index);
const_reference at(size_type index) const;
reference front();
const_reference front() const;
reference back();
const_reference back() const;
void fill(const value_type & value, const command_queue & queue);
void swap(array< T, N > & other, const command_queue & queue);
void fill(const value_type & value);
void swap(array< T, N > & other);
const buffer & get_buffer() const;