Range#

[req.range]

A Range can be recursively subdivided into two parts. Subdivision is done by calling splitting constructor of a Range. There are two types of splitting constructors:

  • Basic splitting constructor. In this constructor, it is recommended that the division is done into nearly equal parts, but it is not required. Splitting as evenly as possible typically yields the best parallelism.

  • Proportional splitting constructor. This constructor is optional and can be omitted. When using this type of constructor, for the best results, follow the given proportion with rounding to the nearest integer if necessary.

Ideally, a range is recursively splittable until the parts represent portions of work that are more efficient to execute serially rather than split further. The amount of work represented by Range typically depends on higher level context, therefore a typical type that models a Range should provide a way to control the degree of splitting. For example, the template class blocked_range has the grainsize parameter that specifies the biggest range considered indivisible.

If the set of values has a sense of direction, by convention the splitting constructor should construct the second part of the range and update its argument to be the first part of the range. This causes the parallel_for, parallel_reduce, and parallel_scan algorithms, when running sequentially, to work across a range in the increasing order, which is typical of an ordinary sequential loop.

Because a Range declares splitting and copy constructors, the default constructor for it is not generated automatically. You need to explicitly define the default constructor or add any other constructor to create an instance of a Range type in the program.

A type R meets Range if it satisfies the following requirements:


Range Requirements: Pseudo-Signature, Semantics

R::R(const R&)#

Copy constructor.

R::~R()#

Destructor.

bool R::empty() const#

True if range is empty.

bool R::is_divisible() const#

True if range can be partitioned into two subranges.

R::R(R &r, split)#

Basic splitting constructor. Splits r into two subranges.

R::R(R &r, proportional_split proportion)#

Optional. Proportional splitting constructor. Splits r into two subranges in accordance with proportion.

See also: