| Home | Libraries | People | FAQ | More

## Class template buffer_iterator

boost::compute::buffer_iterator — An iterator for values in a buffer.

## Synopsis

    // In header: <boost/compute/iterator/buffer_iterator.hpp>

    template<typename T>
    class buffer_iterator {
    public:
      // types
      typedef unspecified                 super_type;
      typedef super_type::reference       reference;
      typedef super_type::difference_type difference_type;

      // public member functions
      buffer_iterator();
      buffer_iterator(const buffer &, size_t);
      buffer_iterator(const buffer_iterator< T > &);
      buffer_iterator< T > & operator=(const buffer_iterator< T > &);
      ~buffer_iterator();
      const buffer & get_buffer() const;
      size_t get_index() const;
      T read(command_queue &) const;
      void write(const T &, command_queue &);
    };

## Description

The buffer_iterator class iterates over values in a memory buffer on a compute device. It is the most commonly used iterator in Boost.Compute and is used by the vector<T> and array<T, N> container classes.

Buffer iterators store a reference to a memory buffer along with an index into that memory buffer.

The buffer_iterator class allows for arbitrary OpenCL memory objects (including those created outside of Boost.Compute) to be used with the Boost.Compute algorithms (such as transform() and sort()). For example, to reverse the contents of an OpenCL memory buffer containing a set of integers:

See Also: buffer, make_buffer_iterator()

### `buffer_iterator` public member functions

1.     buffer_iterator();

2.     buffer_iterator(const buffer & buffer, size_t index);

3.     buffer_iterator(const buffer_iterator< T > & other);

4.     buffer_iterator< T > & operator=(const buffer_iterator< T > & other);

5.     ~buffer_iterator();

6.     const buffer & get_buffer() const;

7.     size_t get_index() const;

8.     T read(command_queue & queue) const;

9.     void write(const T & value, command_queue & queue);