| Home | Libraries | People | FAQ | More

## Class template extents

boost::compute::extents

## Synopsis

    // In header: <boost/compute/utility/extents.hpp>

    template<size_t N>
    class extents {
    public:
      // types
      typedef size_t                     size_type;
      typedef boost::array< size_t, N >  array_type;
      typedef array_type::iterator       iterator;
      typedef array_type::const_iterator const_iterator;

      // public member functions
      extents();
      explicit extents(size_t);
      extents(std::initializer_list< size_t >);
      size_type size() const;
      size_type linear() const;
      size_t * data();
      const size_t * data() const;
      iterator begin();
      const_iterator begin() const;
      const_iterator cbegin() const;
      iterator end();
      const_iterator end() const;
      const_iterator cend() const;
      size_t & operator[](size_t);
      const size_t & operator[](size_t) const;
      bool operator==(const extents &) const;
      bool operator!=(const extents &) const;

      // public data members
      static const size_type static_size;
    };

## Description

The extents class contains an array of n-dimensional extents.

See Also: dim()

### `extents` public member functions

1.     extents();

   Creates an extents object with each component set to zero.

   For example:

       extents<3> exts(); // (0, 0, 0)

2.     explicit extents(size_t value);

   Creates an extents object with each component set to `value`.

   For example:

       extents<3> exts(1); // (1, 1, 1)

3.     extents(std::initializer_list< size_t > values);

   Creates an extents object with `values`.

4.     size_type size() const;

   Returns the size (i.e. dimensionality) of the extents array.

5.     size_type linear() const;

   Returns the linear size of the extents. This is equivalent to the product of each extent in each dimension.

6.     size_t * data();

   Returns a pointer to the extents data array.

   This is useful for passing the extents data to OpenCL APIs which expect an array of `size_t`.

7.     const size_t * data() const;

   This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

8.     iterator begin();

9.     const_iterator begin() const;

10.     const_iterator cbegin() const;

11.     iterator end();

12.     const_iterator end() const;

13.     const_iterator cend() const;

14.     size_t & operator[](size_t index);

    Returns a reference to the extent at `index`.

15.     const size_t & operator[](size_t index) const;

    This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

16.     bool operator==(const extents & other) const;

    Returns `true` if the extents in `*this` are the same as `other`.

17.     bool operator!=(const extents & other) const;

    Returns `true` if the extents in `*this` are not the same as `other`.