...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::extents
// 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; // construct/copy/destruct extents(); explicit extents(size_t); extents(std::initializer_list< size_t >); // public member functions 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; };
The extents class contains an array of n-dimensional extents.
See Also:
dim()
extents
public
construct/copy/destructextents();
Creates an extents object with each component set to zero.
For example:
extents<3> exts(); // (0, 0, 0)
explicit extents(size_t value);
Creates an extents object with each component set to value
.
For example:
extents<3> exts(1); // (1, 1, 1)
extents(std::initializer_list< size_t > values);Creates an extents object with
values
. extents
public member functionssize_type size() const;Returns the size (i.e. dimensionality) of the extents array.
size_type linear() const;
Returns the linear size of the extents. This is equivalent to the product of each extent in each dimension.
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
.
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.
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 index);Returns a reference to the extent at
index
. 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.
bool operator==(const extents & other) const;Returns
true
if the extents in *this
are the same as other
. bool operator!=(const extents & other) const;Returns
true
if the extents in *this
are not the same as other
.