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 the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Class template array

boost::compute::array — A fixed-size container.

Synopsis

// 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;
};

Description

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:

vector<T>

array public construct/copy/destruct

  1. explicit array(const context & context = system::default_context());
  2. array(const array< T, N > & other);
  3. array(const boost::array< T, N > & array, 
          const context & context = system::default_context());
  4. array(const array< T, N > & other, const command_queue & queue);
  5. array< T, N > & operator=(const array< T, N > & other);
  6. array< T, N > & operator=(const boost::array< T, N > & array);
  7. ~array();

array public member functions

  1. iterator begin();
  2. const_iterator begin() const;
  3. const_iterator cbegin() const;
  4. iterator end();
  5. const_iterator end() const;
  6. const_iterator cend() const;
  7. reverse_iterator rbegin();
  8. const_reverse_iterator rbegin() const;
  9. const_reverse_iterator crbegin() const;
  10. reverse_iterator rend();
  11. const_reverse_iterator rend() const;
  12. const_reverse_iterator crend() const;
  13. size_type size() const;
  14. bool empty() const;
  15. size_type max_size() const;
  16. reference operator[](size_type index);
  17. const_reference operator[](size_type index) const;
  18. reference at(size_type index);
  19. const_reference at(size_type index) const;
  20. reference front();
  21. const_reference front() const;
  22. reference back();
  23. const_reference back() const;
  24. void fill(const value_type & value, const command_queue & queue);
  25. void swap(array< T, N > & other, const command_queue & queue);
  26. void fill(const value_type & value);
  27. void swap(array< T, N > & other);
  28. const buffer & get_buffer() const;

array private member functions

  1. command_queue default_queue() const;

PrevUpHomeNext